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 02:14:10 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-12-01 02:14:10 +0300
commit528d5dcfe266e4b18f87b9fb51cfcb8e7782f8cc (patch)
tree91ee8ab3bae1daac646e777f3f32093ab2290393 /core/Log.php
parent3563fe0c319d8925af57cbd26695d1bc4b63d2ef (diff)
#6622 Logger refactoring: moved "log message processing" into "Processor" objects (to prepare the transition to Monolog)
Diffstat (limited to 'core/Log.php')
-rw-r--r--core/Log.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/core/Log.php b/core/Log.php
index a59d6857f6..54844f7dbb 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -140,10 +140,17 @@ class Log extends Singleton
private $currentLogLevel = self::WARN;
/**
+ * Processors process log messages before they are being sent to backends.
+ *
+ * @var callable[]
+ */
+ private $processors = array();
+
+ /**
* The array of callbacks executed when logging a message. Each callback writes a log
* message to a logging backend.
*
- * @var array
+ * @var callable[]
*/
private $writers = array();
@@ -175,12 +182,14 @@ class Log extends Singleton
* @param callable[] $writers
* @param string $logMessageFormat
* @param int $logLevel
+ * @param callable[] $processors
*/
- public function __construct(array $writers, $logMessageFormat, $logLevel)
+ public function __construct(array $writers, $logMessageFormat, $logLevel, array $processors)
{
$this->writers = $writers;
$this->logMessageFormat = $logMessageFormat;
$this->currentLogLevel = $logLevel;
+ $this->processors = $processors;
}
/**
@@ -286,17 +295,9 @@ class Log extends Singleton
}
$datetime = date("Y-m-d H:i:s");
- if (is_string($message)
- && !empty($sprintfParams)
- ) {
- // handle array sprintf parameters
- foreach ($sprintfParams as &$param) {
- if (is_array($param)) {
- $param = json_encode($param);
- }
- }
- $message = vsprintf($message, $sprintfParams);
+ foreach ($this->processors as $processor) {
+ $message = $processor($message, $sprintfParams, $level);
}
if (version_compare(phpversion(), '5.3.6', '>=')) {