-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
39 lines (27 loc) · 1.2 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use JoeBengalen\Logger;
use JoeBengalen\Logger\MessageInterface;
use Psr\Log\LogLevel;
error_reporting(-1);
ini_set('display_errors', 1);
// Set default timezone
date_default_timezone_set('Europe/Amsterdam');
require_once 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$logFile = __DIR__ . DIRECTORY_SEPARATOR . 'default.log';
$sqliteFile = __DIR__ . DIRECTORY_SEPARATOR . 'logging.sqlite';
$collection = new Logger\Handler\CollectionHandler();
$logger = new Logger\Logger([
$collection,
new Logger\Handler\FileHandler($logFile),
//new Logger\Handler\DatabaseHandler(new PDO("sqlite:{$sqliteFile}", null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION])),
// custom handler only showing debug messages
function (MessageInterface $message) {
if ($message->getLevel() == LogLevel::DEBUG) {
echo "Debugging: {$message->getMessage()}\n";
}
}
]);
$logger->debug('Some debug information ...');
$logger->info("User '{username}' created.", array('username' => 'JoeBengalen', 'extra' => true));
$logger->critical("Unexpected Exception occurred.", ['exception' => new \Exception('Something went horribly wrong :(')]);
var_dump($collection->getAllMessages());