From 288c07e4fc6487c88e41c054876f60badc1cde2c Mon Sep 17 00:00:00 2001 From: mwithheld <796986+mwithheld@users.noreply.github.com> Date: Sun, 11 Jul 2021 13:17:52 -0700 Subject: Add log handlers syslog and errorlog (#17745) Issue#9400 --- plugins/Monolog/config/config.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'plugins') diff --git a/plugins/Monolog/config/config.php b/plugins/Monolog/config/config.php index 315c481366..887fa12aaa 100644 --- a/plugins/Monolog/config/config.php +++ b/plugins/Monolog/config/config.php @@ -17,6 +17,8 @@ return array( 'file' => 'Piwik\Plugins\Monolog\Handler\FileHandler', 'screen' => 'Piwik\Plugins\Monolog\Handler\WebNotificationHandler', 'database' => 'Piwik\Plugins\Monolog\Handler\DatabaseHandler', + 'syslog' => 'Piwik\Plugins\Monolog\Handler\SyslogHandler', + 'errorlog' => 'Piwik\Plugins\Monolog\Handler\ErrorLogHandler', ), 'log.handlers' => DI\factory(function (\DI\Container $c) { if ($c->has('ini.log.log_writers')) { @@ -98,6 +100,14 @@ return array( ->constructor(DI\get('log.file.filename'), DI\get('log.level.file')) ->method('setFormatter', DI\get('log.lineMessageFormatter.file')), + 'Piwik\Plugins\Monolog\Handler\SyslogHandler' => DI\create() + ->constructor('matomo', null, DI\get('log.level.syslog')) + ->method('setFormatter', DI\get('log.lineMessageFormatter.file')), + + 'Piwik\Plugins\Monolog\Handler\ErrorLogHandler' => DI\create() + ->constructor(null, DI\get('log.level.errorlog')) + ->method('setFormatter', DI\get('log.lineMessageFormatter.file')), + 'Piwik\Plugins\Monolog\Handler\DatabaseHandler' => DI\create() ->constructor(DI\get('log.level.database')) ->method('setFormatter', DI\get('log.lineMessageFormatter')), @@ -147,6 +157,26 @@ return array( return $c->get('log.level'); }), + 'log.level.syslog' => DI\factory(function (ContainerInterface $c) { + if ($c->has('ini.log.log_level_syslog')) { + $level = Log::getMonologLevelIfValid($c->get('ini.log.log_level_syslog')); + if ($level !== null) { + return $level; + } + } + return $c->get('log.level'); + }), + + 'log.level.errorlog' => DI\factory(function (ContainerInterface $c) { + if ($c->has('ini.log.log_level_errorlog')) { + $level = Log::getMonologLevelIfValid($c->get('ini.log.log_level_errorlog')); + if ($level !== null) { + return $level; + } + } + return $c->get('log.level'); + }), + 'log.file.filename' => DI\factory(function (ContainerInterface $c) { $logPath = $c->get('ini.log.logger_file_path'); -- cgit v1.2.3