diff --git a/PHPCI/Helper/LoggerConfig.php b/PHPCI/Helper/LoggerConfig.php index 958f76eb..014805f2 100644 --- a/PHPCI/Helper/LoggerConfig.php +++ b/PHPCI/Helper/LoggerConfig.php @@ -8,6 +8,8 @@ use Monolog\Logger; class LoggerConfig { + const KEY_AlwaysLoaded = "_"; + private $config; /** @@ -32,20 +34,25 @@ class LoggerConfig { * @return Logger */ public function GetFor($name) { + $handlers = $this->getHandlers(self::KEY_AlwaysLoaded); + $handlers = array_merge($handlers, $this->getHandlers($name)); + return new Logger($name, $handlers); + } + + protected function getHandlers($key) { $handlers = array(); // They key is expected to either be an array or // a callable function that returns an array - if (isset($this->config[$name])) { - if (is_callable($this->config[$name])) { - $handlers = call_user_func($this->config[$name]); + if (isset($this->config[$key])) { + if (is_callable($this->config[$key])) { + $handlers = call_user_func($this->config[$key]); } - elseif(is_array($this->config[$name])) { - $handlers = $this->config[$name]; + elseif(is_array($this->config[$key])) { + $handlers = $this->config[$key]; } } - - return new Logger($name, $handlers); + return $handlers; } } \ No newline at end of file diff --git a/loggerconfig.php.example b/loggerconfig.php.example index a5daccfe..dad42f17 100644 --- a/loggerconfig.php.example +++ b/loggerconfig.php.example @@ -1,9 +1,16 @@ function() { + return array( + new \Monolog\Handler\StreamHandler('c:\temp\errors.log', \Monolog\Logger::ERROR), + ); + }, + + /** Loggers for the RunCommand */ 'RunCommand' => function() { return array( - new \Monolog\Handler\StreamHandler('path/to/logs/errors', \Monolog\Logger::ERROR), - new \Monolog\Handler\RotatingFileHandler('path/to/logs/everything',3, \Monolog\Logger::INFO), + new \Monolog\Handler\RotatingFileHandler('c:\temp\everything',3, \Monolog\Logger::INFO), ); } ); \ No newline at end of file