diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-01 06:17:17 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-01 06:17:17 +0300 |
commit | 8f8275426fb62c61627b6e77ab0a377eb4864b71 (patch) | |
tree | a2de6ab57c974a72b3cd67087ad95aa9520ac416 | |
parent | e7474e669e221a3fd2b0f0f941364a872053d678 (diff) |
#6622 Logger refactoring: use Monolog constants
-rw-r--r-- | core/Log.php | 23 | ||||
-rw-r--r-- | core/Log/Backend/StdErrBackend.php | 3 |
2 files changed, 24 insertions, 2 deletions
diff --git a/core/Log.php b/core/Log.php index f759b351d7..7ca7721f5e 100644 --- a/core/Log.php +++ b/core/Log.php @@ -8,6 +8,7 @@ namespace Piwik; +use Monolog\Logger; use Piwik\Container\StaticContainer; use Piwik\Db; @@ -255,7 +256,7 @@ class Log extends Singleton 'message' => $message, 'context' => $parameters, 'channel' => 'piwik', - 'level' => $level, + 'level' => $this->getMonologLevel($level), 'level_name' => self::getStringLevel($level), 'time' => new \DateTime(), 'extra' => array(), @@ -336,4 +337,24 @@ class Log extends Singleton ); return $levelToName[$level]; } + + private function getMonologLevel($level) + { + switch ($level) { + case self::ERROR: + return Logger::ERROR; + case self::WARN: + return Logger::WARNING; + case self::INFO: + return Logger::INFO; + case self::DEBUG: + return Logger::DEBUG; + case self::VERBOSE: + return Logger::DEBUG; + case self::NONE: + default: + // Highest level possible, need to do better in the future... + return Logger::EMERGENCY; + } + } } diff --git a/core/Log/Backend/StdErrBackend.php b/core/Log/Backend/StdErrBackend.php index 8f8bb00252..32443322f6 100644 --- a/core/Log/Backend/StdErrBackend.php +++ b/core/Log/Backend/StdErrBackend.php @@ -8,6 +8,7 @@ namespace Piwik\Log\Backend; +use Monolog\Logger; use Piwik\Log; use Piwik\Log\Formatter\Formatter; @@ -30,7 +31,7 @@ class StdErrBackend extends Backend public function __invoke(array $record, Log $logger) { - if ($record['level'] != Log::ERROR) { + if ($record['level'] < Logger::ERROR) { return; } |