diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-10 05:06:16 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-10 05:06:16 +0300 |
commit | 76a5fe098e5a939a2709867133d74b9441c9a4d9 (patch) | |
tree | 74f3824b52b2e115ed85fc40a44425c8c754be15 /config/environment | |
parent | 6bf0530c94cfd08f11bf6c35d56102b0345c8eca (diff) |
#6622 Logger refactoring: introduced a DI config for the test environment
Diffstat (limited to 'config/environment')
-rw-r--r-- | config/environment/cli.php | 29 | ||||
-rw-r--r-- | config/environment/test.php | 8 |
2 files changed, 37 insertions, 0 deletions
diff --git a/config/environment/cli.php b/config/environment/cli.php new file mode 100644 index 0000000000..f924c31b20 --- /dev/null +++ b/config/environment/cli.php @@ -0,0 +1,29 @@ +<?php + +use Interop\Container\ContainerInterface; +use Monolog\Logger; +use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter; +use Symfony\Bridge\Monolog\Handler\ConsoleHandler; +use Symfony\Component\Console\Output\OutputInterface; + +return array( + + // Log + 'log.handlers' => array( + DI\link('Symfony\Bridge\Monolog\Handler\ConsoleHandler'), + ), + 'Symfony\Bridge\Monolog\Handler\ConsoleHandler' => DI\factory(function (ContainerInterface $c) { + // Override the default verbosity map to make it more verbose by default + $verbosityMap = array( + OutputInterface::VERBOSITY_NORMAL => Logger::INFO, + OutputInterface::VERBOSITY_VERBOSE => Logger::DEBUG, + OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::DEBUG, + OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG, + ); + $handler = new ConsoleHandler(null, true, $verbosityMap); + $handler->setFormatter(new ConsoleFormatter($c->get('log.console.format'), null, true, true)); + return $handler; + }), + 'log.console.format' => '%start_tag%%level_name% %extra.class%[%datetime%]%end_tag% %message%' . PHP_EOL, + +); diff --git a/config/environment/test.php b/config/environment/test.php new file mode 100644 index 0000000000..95857fd134 --- /dev/null +++ b/config/environment/test.php @@ -0,0 +1,8 @@ +<?php + +return array( + + // Disable logging + 'Psr\Log\LoggerInterface' => DI\object('Psr\Log\NullLogger'), + +); |