Updated how monolog handlers are registered so that it is possible to overwrite them via local config

This commit is contained in:
Alejandro Celaya 2019-11-30 09:28:09 +01:00
parent 4401824716
commit 5d76a55c46
3 changed files with 11 additions and 9 deletions

View File

@ -48,7 +48,10 @@ return [
'loggers' => [ 'loggers' => [
'Shlink' => [ 'Shlink' => [
'handlers' => ['shlink_rotating_handler'], 'handlers' => [
// Using a key allows for this to be overwritten
'shlink_handler' => 'shlink_rotating_handler',
],
'processors' => ['exception_with_new_line', 'psr3'], 'processors' => ['exception_with_new_line', 'psr3'],
], ],
'Access' => [ 'Access' => [

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
@ -9,9 +10,6 @@ $isSwoole = extension_loaded('swoole');
// For swoole, send logs to standard output // For swoole, send logs to standard output
$logger = $isSwoole ? [ $logger = $isSwoole ? [
'handlers' => [ 'handlers' => [
'shlink_rotating_handler' => [
'level' => Logger::EMERGENCY, // This basically disables regular file logs
],
'shlink_stdout_handler' => [ 'shlink_stdout_handler' => [
'class' => StreamHandler::class, 'class' => StreamHandler::class,
'level' => Logger::DEBUG, 'level' => Logger::DEBUG,
@ -22,7 +20,9 @@ $logger = $isSwoole ? [
'loggers' => [ 'loggers' => [
'Shlink' => [ 'Shlink' => [
'handlers' => ['shlink_stdout_handler'], 'handlers' => [
'shlink_handler' => 'shlink_stdout_handler',
],
], ],
], ],
] : [ ] : [

View File

@ -131,9 +131,6 @@ return [
'logger' => [ 'logger' => [
'handlers' => [ 'handlers' => [
'shlink_rotating_handler' => [
'level' => Logger::EMERGENCY, // This basically disables regular file logs
],
'shlink_stdout_handler' => [ 'shlink_stdout_handler' => [
'class' => StreamHandler::class, 'class' => StreamHandler::class,
'level' => Logger::INFO, 'level' => Logger::INFO,
@ -144,7 +141,9 @@ return [
'loggers' => [ 'loggers' => [
'Shlink' => [ 'Shlink' => [
'handlers' => ['shlink_stdout_handler'], 'handlers' => [
'shlink_handler' => 'shlink_stdout_handler',
],
], ],
], ],
], ],