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;
|
|
|
|
|
2023-05-07 14:18:19 +03:00
|
|
|
use Laminas\ServiceManager\Factory\InvokableFactory;
|
2022-06-04 09:59:17 +03:00
|
|
|
use Monolog\Level;
|
2016-08-08 12:56:19 +03:00
|
|
|
use Monolog\Logger;
|
2019-09-11 21:25:04 +03:00
|
|
|
use Psr\Log\LoggerInterface;
|
2023-05-07 14:18:19 +03:00
|
|
|
use Psr\Log\NullLogger;
|
2022-06-04 09:59:17 +03:00
|
|
|
use Shlinkio\Shlink\Common\Logger\LoggerFactory;
|
|
|
|
use Shlinkio\Shlink\Common\Logger\LoggerType;
|
2023-05-07 14:18:19 +03:00
|
|
|
use Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware;
|
2024-02-04 16:16:42 +03:00
|
|
|
use Shlinkio\Shlink\Common\Middleware\RequestIdMiddleware;
|
2019-02-27 00:56:43 +03:00
|
|
|
|
2023-05-07 14:18:19 +03:00
|
|
|
use function Shlinkio\Shlink\Config\runningInRoadRunner;
|
2019-11-30 19:59:04 +03:00
|
|
|
|
2023-05-07 14:18:19 +03:00
|
|
|
return (static function (): array {
|
|
|
|
$common = [
|
|
|
|
'level' => Level::Info->value,
|
2024-02-04 16:16:42 +03:00
|
|
|
'processors' => [RequestIdMiddleware::class],
|
|
|
|
'line_format' =>
|
|
|
|
'[%datetime%] [%extra.' . RequestIdMiddleware::ATTRIBUTE . '%] %channel%.%level_name% - %message%',
|
2023-05-07 14:18:19 +03:00
|
|
|
];
|
2016-08-08 12:17:14 +03:00
|
|
|
|
2023-05-07 14:18:19 +03:00
|
|
|
return [
|
2018-11-25 19:14:03 +03:00
|
|
|
|
2023-05-07 14:18:19 +03:00
|
|
|
'logger' => [
|
|
|
|
'Shlink' => [
|
|
|
|
'type' => LoggerType::FILE->value,
|
|
|
|
...$common,
|
|
|
|
],
|
|
|
|
'Access' => [
|
|
|
|
'type' => LoggerType::STREAM->value,
|
|
|
|
'destination' => 'php://stderr',
|
|
|
|
'add_new_line' => ! runningInRoadRunner(),
|
|
|
|
...$common,
|
|
|
|
],
|
2018-11-25 19:14:03 +03:00
|
|
|
],
|
2023-05-07 14:18:19 +03:00
|
|
|
|
|
|
|
'dependencies' => [
|
|
|
|
'factories' => [
|
|
|
|
'Logger_Shlink' => [LoggerFactory::class, 'Shlink'],
|
|
|
|
'Logger_Access' => [LoggerFactory::class, 'Access'],
|
|
|
|
NullLogger::class => InvokableFactory::class,
|
|
|
|
],
|
|
|
|
'aliases' => [
|
|
|
|
'logger' => 'Logger_Shlink',
|
|
|
|
Logger::class => 'Logger_Shlink',
|
|
|
|
LoggerInterface::class => 'Logger_Shlink',
|
|
|
|
AccessLogMiddleware::LOGGER_SERVICE_NAME => 'Logger_Access',
|
|
|
|
],
|
2019-09-11 21:25:04 +03:00
|
|
|
],
|
2018-11-25 19:14:03 +03:00
|
|
|
|
2023-05-07 14:18:19 +03:00
|
|
|
];
|
|
|
|
})();
|