You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
676 B
PHP
29 lines
676 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use jrosset\ExtendedMonolog\ExceptionLogger;
|
|
use jrosset\ExtendedMonolog\LogDirectoryHandler;
|
|
use Monolog\Handler\StreamHandler;
|
|
use Monolog\Logger;
|
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */
|
|
$logger = new ExceptionLogger(
|
|
'test',
|
|
[
|
|
new StreamHandler(STDOUT),
|
|
new LogDirectoryHandler(__DIR__ . '/logs/'),
|
|
]
|
|
);
|
|
|
|
try {
|
|
$logger->info('START');
|
|
|
|
throw new RuntimeException('An unexpected error occurs');
|
|
|
|
/** @noinspection PhpUnreachableStatementInspection */
|
|
$logger->info('END');
|
|
}
|
|
catch (Throwable $exception) {
|
|
$logger->exception(Logger::ERROR, $exception);
|
|
} |