2016-08-08 12:17:14 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-10-20 13:37:26 +03:00
|
|
|
namespace Shlinkio\Shlink;
|
|
|
|
|
2019-11-30 19:59:04 +03:00
|
|
|
use Monolog\Formatter;
|
|
|
|
use Monolog\Handler;
|
2016-08-08 12:56:19 +03:00
|
|
|
use Monolog\Logger;
|
2018-10-20 13:37:26 +03:00
|
|
|
use Monolog\Processor;
|
2019-11-30 19:59:04 +03:00
|
|
|
use MonologFactory\DiContainerLoggerFactory;
|
2020-02-19 21:37:47 +03:00
|
|
|
use PhpMiddleware\RequestId;
|
2019-09-11 21:25:04 +03:00
|
|
|
use Psr\Log\LoggerInterface;
|
2019-02-27 00:56:43 +03:00
|
|
|
|
2018-10-20 13:37:26 +03:00
|
|
|
use const PHP_EOL;
|
2016-08-08 12:56:19 +03:00
|
|
|
|
2019-11-30 19:59:04 +03:00
|
|
|
$processors = [
|
|
|
|
'exception_with_new_line' => [
|
|
|
|
'name' => Common\Logger\Processor\ExceptionWithNewLineProcessor::class,
|
|
|
|
],
|
|
|
|
'psr3' => [
|
|
|
|
'name' => Processor\PsrLogMessageProcessor::class,
|
|
|
|
],
|
2020-02-19 21:37:47 +03:00
|
|
|
'request_id' => RequestId\MonologProcessor::class,
|
2019-11-30 19:59:04 +03:00
|
|
|
];
|
|
|
|
$formatter = [
|
|
|
|
'name' => Formatter\LineFormatter::class,
|
|
|
|
'params' => [
|
2020-02-19 21:37:47 +03:00
|
|
|
'format' => '[%datetime%] [%extra.request_id%] %channel%.%level_name% - %message%' . PHP_EOL,
|
2019-11-30 20:08:30 +03:00
|
|
|
'allow_inline_line_breaks' => true,
|
2019-11-30 19:59:04 +03:00
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2016-08-08 12:17:14 +03:00
|
|
|
return [
|
|
|
|
|
|
|
|
'logger' => [
|
2019-11-30 19:59:04 +03:00
|
|
|
'Shlink' => [
|
|
|
|
'name' => 'Shlink',
|
|
|
|
'handlers' => [
|
|
|
|
'shlink_handler' => [
|
|
|
|
'name' => Handler\RotatingFileHandler::class,
|
|
|
|
'params' => [
|
|
|
|
'level' => Logger::INFO,
|
|
|
|
'filename' => 'data/log/shlink_log.log',
|
|
|
|
'max_files' => 30,
|
2020-02-08 13:50:25 +03:00
|
|
|
'file_permission' => 0666,
|
2019-11-30 19:59:04 +03:00
|
|
|
],
|
|
|
|
'formatter' => $formatter,
|
|
|
|
],
|
2018-10-20 13:37:26 +03:00
|
|
|
],
|
2019-11-30 19:59:04 +03:00
|
|
|
'processors' => $processors,
|
2018-10-20 13:37:26 +03:00
|
|
|
],
|
2019-11-30 19:59:04 +03:00
|
|
|
'Access' => [
|
|
|
|
'name' => 'Access',
|
|
|
|
'handlers' => [
|
|
|
|
'access_handler' => [
|
|
|
|
'name' => Handler\StreamHandler::class,
|
|
|
|
'params' => [
|
|
|
|
'level' => Logger::INFO,
|
|
|
|
'stream' => 'php://stdout',
|
|
|
|
],
|
|
|
|
'formatter' => $formatter,
|
2019-11-30 11:28:09 +03:00
|
|
|
],
|
2018-11-25 19:14:03 +03:00
|
|
|
],
|
2019-11-30 19:59:04 +03:00
|
|
|
'processors' => $processors,
|
2018-11-25 19:14:03 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
'dependencies' => [
|
|
|
|
'factories' => [
|
2019-11-30 19:59:04 +03:00
|
|
|
'Logger_Shlink' => [DiContainerLoggerFactory::class, 'Shlink'],
|
|
|
|
'Logger_Access' => [DiContainerLoggerFactory::class, 'Access'],
|
2018-11-25 19:14:03 +03:00
|
|
|
],
|
2019-09-11 21:25:04 +03:00
|
|
|
'aliases' => [
|
|
|
|
'logger' => 'Logger_Shlink',
|
|
|
|
Logger::class => 'Logger_Shlink',
|
|
|
|
LoggerInterface::class => 'Logger_Shlink',
|
|
|
|
],
|
2018-11-25 19:14:03 +03:00
|
|
|
],
|
|
|
|
|
2020-01-01 23:11:53 +03:00
|
|
|
'mezzio-swoole' => [
|
2018-11-25 19:14:03 +03:00
|
|
|
'swoole-http-server' => [
|
|
|
|
'logger' => [
|
2019-05-13 20:16:14 +03:00
|
|
|
'logger-name' => 'Logger_Access',
|
2018-11-25 19:14:03 +03:00
|
|
|
],
|
2016-08-08 12:17:14 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
];
|