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-01 05:43:03 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-12-01 05:51:37 +0300
commit0794be0d5551998b683ac934e00604d277fe69e9 (patch)
tree26a43fbc68f219fc6116ceebfed132ad1c9107dd /core/Log.php
parentf1fae09be4507bd9dedfc949deab98108b47b23e (diff)
#6622 Logger refactoring: use a "record" array similar to Monolog to ease future transition
Diffstat (limited to 'core/Log.php')
-rw-r--r--core/Log.php36
1 files changed, 30 insertions, 6 deletions
diff --git a/core/Log.php b/core/Log.php
index 4091fa532d..f759b351d7 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -244,25 +244,36 @@ class Log extends Singleton
return $this->currentLogLevel;
}
- private function doLog($level, $message, $sprintfParams = array())
+ private function doLog($level, $message, $parameters = array())
{
if (!$this->shouldLoggerLog($level)) {
return;
}
+ // Create a record similar to Monolog to ease future transition
+ $record = array(
+ 'message' => $message,
+ 'context' => $parameters,
+ 'channel' => 'piwik',
+ 'level' => $level,
+ 'level_name' => self::getStringLevel($level),
+ 'time' => new \DateTime(),
+ 'extra' => array(),
+ );
+
foreach ($this->processors as $processor) {
- $message = $processor($message, $sprintfParams, $level);
+ $record = $processor($record);
}
- $tag = $this->getLoggingClassName();
+ $record['extra']['class'] = $this->getLoggingClassName();
- $this->writeMessage($level, $tag, date("Y-m-d H:i:s"), $message);
+ $this->writeMessage($record, date("Y-m-d H:i:s"));
}
- private function writeMessage($level, $tag, $datetime, $message)
+ private function writeMessage(array $record)
{
foreach ($this->writers as $writer) {
- call_user_func($writer, $level, $tag, $datetime, $message, $this);
+ call_user_func($writer, $record, $this);
}
}
@@ -312,4 +323,17 @@ class Log extends Singleton
}
return $tag;
}
+
+ private function getStringLevel($level)
+ {
+ static $levelToName = array(
+ Log::NONE => 'NONE',
+ Log::ERROR => 'ERROR',
+ Log::WARN => 'WARN',
+ Log::INFO => 'INFO',
+ Log::DEBUG => 'DEBUG',
+ Log::VERBOSE => 'VERBOSE'
+ );
+ return $levelToName[$level];
+ }
}