diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-01-12 00:59:12 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2015-01-12 00:59:12 +0300 |
commit | 5ca99240fea3f69f29e3a385d60ca261095229d1 (patch) | |
tree | f13b786ec28c50fbfb38019bb8bee51fe9b7abcd /misc | |
parent | b3251b8de08150ce9dd861e7a670c9c8b3cc079d (diff) |
Better fix for #6978 Keep logging in configured backends (e.g. file) and no additional class
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cron/archive.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/misc/cron/archive.php b/misc/cron/archive.php index d4dd03eb08..524fe8f377 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -9,6 +9,8 @@ * @package Piwik */ +use Monolog\Handler\StreamHandler; +use Monolog\Logger; use Piwik\Container\StaticContainer; use Piwik\Log\WebCronArchiveLogger; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; @@ -65,11 +67,15 @@ if (isset($_SERVER['argv']) && Piwik\Console::isSupported()) { // just like for CLI StaticContainer::setEnvironment('cli'); /** @var ConsoleHandler $consoleLogHandler */ - $consoleLogHandler = StaticContainer::getContainer()->get('Symfony\Bridge\Monolog\Handler\ConsoleHandler'); + $consoleLogHandler = StaticContainer::get('Symfony\Bridge\Monolog\Handler\ConsoleHandler'); $consoleLogHandler->setOutput(new ConsoleOutput(OutputInterface::VERBOSITY_VERBOSE)); } else { - // HTTP request: logs needs to be dumped on stdout - StaticContainer::getContainer()->set('Psr\Log\LoggerInterface', new WebCronArchiveLogger); + // HTTP request: logs needs to be dumped in the HTTP response (on top of existing log destinations) + /** @var \Monolog\Logger $logger */ + $logger = StaticContainer::get('Psr\Log\LoggerInterface'); + $handler = new StreamHandler('php://output', Logger::INFO); + $handler->setFormatter(StaticContainer::get('Piwik\Log\Formatter\LineMessageFormatter')); + $logger->pushHandler($handler); } $archiver = new Piwik\CronArchive(); |