<?php
require_once '../vendor/autoload.php';
// Create the file logger with concrete log fils for 'alert' and 'error' levels:
$logger = new \Ite\Logger\FileLogger([
'error' => '../data/logs/errors.log',
'alert' => '../data/logs/errors.log'
]);
// the rest of levels will use the default log file
// log 10 info messages with fake context:
for ($i=0; $i<10; $i++) {
$logger->info("Test info {$i}",['a' => 'test context', 'qwe' => 'alabala', 'q' => [1, 2, 4]]);
}
// log 10 error messages with exception:
for ($i=0; $i<10; $i++) {
$logger->error("Test error {$i}", ['exception' => new Exception("Tesitng exceptions")]);
}
// log 10 alert messages with exception and fake context:
for ($i=0; $i<10; $i++) {
$logger->alert("Test alert {$i}", ['exception' => new Exception("Tesitng exceptions"), 'a' => 'test context', 'qwe' => 'alabala', 'q' => [1, 2, 4]]);
}
|