2016-08-08 11:17:14 +02:00
|
|
|
<?php
|
2019-10-05 17:26:10 +02:00
|
|
|
|
2017-10-12 10:13:20 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-10-20 12:37:26 +02:00
|
|
|
namespace Shlinkio\Shlink;
|
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
use Laminas\ServiceManager\Factory\InvokableFactory;
|
2022-06-04 08:59:17 +02:00
|
|
|
use Monolog\Level;
|
2016-08-08 11:56:19 +02:00
|
|
|
use Monolog\Logger;
|
2020-02-19 19:37:47 +01:00
|
|
|
use PhpMiddleware\RequestId;
|
2019-09-11 20:25:04 +02:00
|
|
|
use Psr\Log\LoggerInterface;
|
2023-05-07 13:18:19 +02:00
|
|
|
use Psr\Log\NullLogger;
|
2022-06-04 08:59:17 +02:00
|
|
|
use Shlinkio\Shlink\Common\Logger\LoggerFactory;
|
|
|
|
use Shlinkio\Shlink\Common\Logger\LoggerType;
|
2023-05-07 13:18:19 +02:00
|
|
|
use Shlinkio\Shlink\Common\Middleware\AccessLogMiddleware;
|
2019-02-26 22:56:43 +01:00
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
use function Shlinkio\Shlink\Config\runningInRoadRunner;
|
2019-11-30 17:59:04 +01:00
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
return (static function (): array {
|
|
|
|
$common = [
|
|
|
|
'level' => Level::Info->value,
|
|
|
|
'processors' => [RequestId\MonologProcessor::class],
|
|
|
|
'line_format' => '[%datetime%] [%extra.request_id%] %channel%.%level_name% - %message%',
|
|
|
|
];
|
2016-08-08 11:17:14 +02:00
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
return [
|
2018-11-25 17:14:03 +01:00
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
'logger' => [
|
|
|
|
'Shlink' => [
|
|
|
|
'type' => LoggerType::FILE->value,
|
|
|
|
...$common,
|
|
|
|
],
|
|
|
|
'Access' => [
|
|
|
|
'type' => LoggerType::STREAM->value,
|
|
|
|
'destination' => 'php://stderr',
|
|
|
|
'add_new_line' => ! runningInRoadRunner(),
|
|
|
|
...$common,
|
|
|
|
],
|
2018-11-25 17:14:03 +01:00
|
|
|
],
|
2023-05-07 13:18:19 +02: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 20:25:04 +02:00
|
|
|
],
|
2018-11-25 17:14:03 +01:00
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
'mezzio-swoole' => [
|
|
|
|
'swoole-http-server' => [
|
|
|
|
'logger' => [
|
|
|
|
// Let's disable mezio-swoole access logging, so that we can provide our own implementation,
|
|
|
|
// consistent for roadrunner and openswoole
|
|
|
|
'logger-name' => NullLogger::class,
|
|
|
|
],
|
2018-11-25 17:14:03 +01:00
|
|
|
],
|
2016-08-08 11:17:14 +02:00
|
|
|
],
|
|
|
|
|
2023-05-07 13:18:19 +02:00
|
|
|
];
|
|
|
|
})();
|