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:
authordiosmosis <diosmosis@users.noreply.github.com>2018-08-11 11:13:55 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2018-08-11 11:13:55 +0300
commit2d7896c3df5540bc109e89782880c0780a6b7bc2 (patch)
tree75584e348745db16b22a4d74f99c9d7c259f0af0 /plugins/Monolog/Handler
parentbc33259f6b6fc730826eceeb2a029eef63e97fc0 (diff)
If warning/error log detected in console command exit w/ code = 1. (#13275)
Diffstat (limited to 'plugins/Monolog/Handler')
-rw-r--r--plugins/Monolog/Handler/FailureLogMessageDetector.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/Monolog/Handler/FailureLogMessageDetector.php b/plugins/Monolog/Handler/FailureLogMessageDetector.php
new file mode 100644
index 0000000000..ea37f4ba08
--- /dev/null
+++ b/plugins/Monolog/Handler/FailureLogMessageDetector.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\Monolog\Handler;
+
+use Monolog\Handler\AbstractHandler;
+use Monolog\Logger;
+
+/**
+ * Handler used to detect whether a certain level of log has been emitted.
+ */
+class FailureLogMessageDetector extends AbstractHandler
+{
+ /**
+ * @var boolean
+ */
+ private $hasEncounteredImportantLog = false;
+
+ public function __construct($level = Logger::WARNING)
+ {
+ parent::__construct($level, $bubble = true);
+ }
+
+ public function handle(array $record)
+ {
+ $this->hasEncounteredImportantLog = true;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasEncounteredImportantLog()
+ {
+ return $this->hasEncounteredImportantLog;
+ }
+
+ /**
+ * for tests
+ */
+ public function reset()
+ {
+ $this->hasEncounteredImportantLog = false;
+ }
+} \ No newline at end of file