Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-12-05 00:09:07 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-12-05 00:09:07 +0300
commita26cf222ff29851440d71cc63df7b3f8650100d3 (patch)
treee6845d779550511ab518c874dbb4088f3435ef27 /core/Console.php
parent7a9f70830a0d32fd56f381aac47d5ed64bf4ed7a (diff)
#6622 Logger refactoring: log in CLI
- follows the verbosity level - formatted with colors
Diffstat (limited to 'core/Console.php')
-rw-r--r--core/Console.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/Console.php b/core/Console.php
index d0268569c9..baf5e6dbef 100644
--- a/core/Console.php
+++ b/core/Console.php
@@ -8,7 +8,9 @@
*/
namespace Piwik;
+use Piwik\Container\StaticContainer;
use Piwik\Plugin\Manager as PluginManager;
+use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -29,12 +31,15 @@ class Console extends Application
);
$this->getDefinition()->addOption($option);
+
+ StaticContainer::loadCliConfig();
}
public function doRun(InputInterface $input, OutputInterface $output)
{
$this->initPiwikHost($input);
$this->initConfig($output);
+ $this->initLoggerOutput($output);
try {
self::initPlugins();
@@ -142,6 +147,21 @@ class Console extends Application
}
}
+ /**
+ * Register the console output into the logger.
+ *
+ * Ideally, this should be done automatically with events:
+ * @see http://symfony.com/fr/doc/current/components/console/events.html
+ * @see Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand()
+ * But it would require to install Symfony's Event Dispatcher.
+ */
+ private function initLoggerOutput(OutputInterface $output)
+ {
+ /** @var ConsoleHandler $consoleLogHandler */
+ $consoleLogHandler = StaticContainer::getContainer()->get('Symfony\Bridge\Monolog\Handler\ConsoleHandler');
+ $consoleLogHandler->setOutput($output);
+ }
+
public static function initPlugins()
{
Plugin\Manager::getInstance()->loadActivatedPlugins();