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
path: root/core/Log
diff options
context:
space:
mode:
Diffstat (limited to 'core/Log')
-rw-r--r--core/Log/Formatter/AddRequestIdFormatter.php4
-rw-r--r--core/Log/Formatter/ErrorHtmlFormatter.php4
-rw-r--r--core/Log/Formatter/ErrorTextFormatter.php4
-rw-r--r--core/Log/Formatter/ExceptionHtmlFormatter.php4
-rw-r--r--core/Log/Formatter/ExceptionTextFormatter.php4
-rw-r--r--core/Log/Formatter/Formatter.php26
-rw-r--r--core/Log/Formatter/HtmlPreFormatter.php4
-rw-r--r--core/Log/Formatter/LineMessageFormatter.php4
8 files changed, 32 insertions, 22 deletions
diff --git a/core/Log/Formatter/AddRequestIdFormatter.php b/core/Log/Formatter/AddRequestIdFormatter.php
index 3de87af71f..9d027f5886 100644
--- a/core/Log/Formatter/AddRequestIdFormatter.php
+++ b/core/Log/Formatter/AddRequestIdFormatter.php
@@ -16,7 +16,7 @@ use Piwik\Log;
*/
class AddRequestIdFormatter extends Formatter
{
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
static $currentRequestKey;
@@ -24,7 +24,7 @@ class AddRequestIdFormatter extends Formatter
$currentRequestKey = substr(Common::generateUniqId(), 0, 5);
}
- $record = $this->next($record, $logger);
+ $record = $this->next($record);
if (! is_string($record['message'])) {
return $record;
diff --git a/core/Log/Formatter/ErrorHtmlFormatter.php b/core/Log/Formatter/ErrorHtmlFormatter.php
index f499df9b10..6b4bbe3ba3 100644
--- a/core/Log/Formatter/ErrorHtmlFormatter.php
+++ b/core/Log/Formatter/ErrorHtmlFormatter.php
@@ -18,12 +18,12 @@ use Piwik\Version;
*/
class ErrorHtmlFormatter extends Formatter
{
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
$message = $record['message'];
if (! $message instanceof Error) {
- return $this->next($record, $logger);
+ return $this->next($record);
}
$errno = $message->errno & error_reporting();
diff --git a/core/Log/Formatter/ErrorTextFormatter.php b/core/Log/Formatter/ErrorTextFormatter.php
index e2651ad638..a4df5990e8 100644
--- a/core/Log/Formatter/ErrorTextFormatter.php
+++ b/core/Log/Formatter/ErrorTextFormatter.php
@@ -16,7 +16,7 @@ use Piwik\Log;
*/
class ErrorTextFormatter extends Formatter
{
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
$message = $record['message'];
@@ -25,6 +25,6 @@ class ErrorTextFormatter extends Formatter
. ' - ' . $message->errstr . "\n" . $message->backtrace;
}
- return $this->next($record, $logger);
+ return $this->next($record);
}
}
diff --git a/core/Log/Formatter/ExceptionHtmlFormatter.php b/core/Log/Formatter/ExceptionHtmlFormatter.php
index 5be62bcb67..70549dbd7e 100644
--- a/core/Log/Formatter/ExceptionHtmlFormatter.php
+++ b/core/Log/Formatter/ExceptionHtmlFormatter.php
@@ -17,10 +17,10 @@ use Piwik\Log;
*/
class ExceptionHtmlFormatter extends Formatter
{
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
if (! $record['message'] instanceof \Exception) {
- return $this->next($record, $logger);
+ return $this->next($record);
}
Common::sendHeader('Content-Type: text/html; charset=utf-8');
diff --git a/core/Log/Formatter/ExceptionTextFormatter.php b/core/Log/Formatter/ExceptionTextFormatter.php
index 1e0bd0ed12..62b850f443 100644
--- a/core/Log/Formatter/ExceptionTextFormatter.php
+++ b/core/Log/Formatter/ExceptionTextFormatter.php
@@ -16,7 +16,7 @@ use Piwik\Log;
*/
class ExceptionTextFormatter extends Formatter
{
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
$message = $record['message'];
@@ -25,6 +25,6 @@ class ExceptionTextFormatter extends Formatter
ExceptionHandler::$debugBacktraceForTests ?: $message->getTraceAsString());
}
- return $this->next($record, $logger);
+ return $this->next($record);
}
}
diff --git a/core/Log/Formatter/Formatter.php b/core/Log/Formatter/Formatter.php
index 66de41423c..264a393991 100644
--- a/core/Log/Formatter/Formatter.php
+++ b/core/Log/Formatter/Formatter.php
@@ -8,6 +8,7 @@
namespace Piwik\Log\Formatter;
+use Monolog\Formatter\FormatterInterface;
use Piwik\Log;
/**
@@ -16,7 +17,7 @@ use Piwik\Log;
* Follows the Chain of responsibility design pattern, so don't forget to call `$this->next(...)`
* at the end of the `format()` method.
*/
-abstract class Formatter
+abstract class Formatter implements FormatterInterface
{
/**
* @var Formatter|null
@@ -24,12 +25,21 @@ abstract class Formatter
protected $next;
/**
- * @param array $record
- * @param Log $logger
- *
- * @return array Updated record.
+ * {@inheritdoc}
+ */
+ public abstract function format(array $record);
+
+ /**
+ * {@inheritdoc}
*/
- public abstract function format(array $record, Log $logger);
+ public function formatBatch(array $records)
+ {
+ foreach ($records as $key => $record) {
+ $records[$key] = $this->format($record);
+ }
+
+ return $records;
+ }
/**
* Chain of responsibility pattern.
@@ -41,12 +51,12 @@ abstract class Formatter
$this->next = $formatter;
}
- protected function next(array $record, Log $logger)
+ protected function next(array $record)
{
if (! $this->next) {
return $record;
}
- return $this->next->format($record, $logger);
+ return $this->next->format($record);
}
}
diff --git a/core/Log/Formatter/HtmlPreFormatter.php b/core/Log/Formatter/HtmlPreFormatter.php
index ecc52fc149..878304e8fa 100644
--- a/core/Log/Formatter/HtmlPreFormatter.php
+++ b/core/Log/Formatter/HtmlPreFormatter.php
@@ -16,9 +16,9 @@ use Piwik\Log;
*/
class HtmlPreFormatter extends Formatter
{
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
- $record = $this->next($record, $logger);
+ $record = $this->next($record);
if (! is_string($record['message'])) {
return $record;
diff --git a/core/Log/Formatter/LineMessageFormatter.php b/core/Log/Formatter/LineMessageFormatter.php
index 4b778f858a..14096ce7ac 100644
--- a/core/Log/Formatter/LineMessageFormatter.php
+++ b/core/Log/Formatter/LineMessageFormatter.php
@@ -28,7 +28,7 @@ class LineMessageFormatter extends Formatter
$this->logMessageFormat = $logMessageFormat;
}
- public function format(array $record, Log $logger)
+ public function format(array $record)
{
if (! is_string($record['message'])) {
throw new \InvalidArgumentException('Trying to log a message that is not a string');
@@ -40,6 +40,6 @@ class LineMessageFormatter extends Formatter
$this->logMessageFormat
);
- return $this->next($record, $logger);
+ return $this->next($record);
}
}