Skip to content

Commit

Permalink
#6622 Logger refactoring: log as in CLI with PHP-CGI for the archiving
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Dec 9, 2014
1 parent 4edf7de commit aad92e9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions misc/cron/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
* @package Piwik
*/

use Piwik\Container\StaticContainer;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;

if (!defined('PIWIK_INCLUDE_PATH')) {
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
}
Expand Down Expand Up @@ -55,6 +60,16 @@

$console->run();
} else { // if running via web request, use CronArchive directly

if (Piwik\Common::isPhpCliMode()) {
// We can run the archive in CLI with `php-cgi` so we have to configure the container/logger
// just like for CLI
StaticContainer::loadCliConfig();
/** @var ConsoleHandler $consoleLogHandler */
$consoleLogHandler = StaticContainer::getContainer()->get('Symfony\Bridge\Monolog\Handler\ConsoleHandler');
$consoleLogHandler->setOutput(new ConsoleOutput(OutputInterface::VERBOSITY_VERBOSE));
}

$archiver = new Piwik\CronArchive();

if (!Piwik\Common::isPhpCliMode()) {
Expand Down

0 comments on commit aad92e9

Please sign in to comment.