From f7a92c0c4e2ccd238c82c4656f2a4e2d16c0e154 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Tue, 25 Jul 2023 15:23:17 +0200 Subject: [PATCH] Add static bool to disable output handler completely --- src/MDOutputHandler.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/MDOutputHandler.php b/src/MDOutputHandler.php index 366e1a2..74f6e95 100644 --- a/src/MDOutputHandler.php +++ b/src/MDOutputHandler.php @@ -13,6 +13,8 @@ final class MDOutputHandler { const FLUSH_TO_LOGFILE_AFTER = 100; + public static bool $disable_completely = false; + /** @var integer */ private int $_verbosity = 0; /** @var string */ @@ -126,6 +128,8 @@ final class MDOutputHandler { */ public function toLog(string $msg, MDConsoleStatus $statusCode = MDConsoleStatus::NOTICE):void { + if (self::$disable_completely === true) return; + // Get parts for generating the message to log. ++$this->_counter; // Increment counter $date = \date("Y-m-d H:i:s"); // Get current date & time. @@ -184,6 +188,11 @@ final class MDOutputHandler { */ public function __destruct() { + if (self::$disable_completely === true) return; + + echo $this->_verbosity; + if ($this->_verbosity < 0) return; + if (!empty($this->_log_queue)) { $this->flush_to_logfile(); }