Add static bool to disable output handler completely

This commit is contained in:
Joshua Ramon Enslin 2023-07-25 15:23:17 +02:00
parent 0b3fbe803e
commit f7a92c0c4e
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -13,6 +13,8 @@ final class MDOutputHandler {
const FLUSH_TO_LOGFILE_AFTER = 100; const FLUSH_TO_LOGFILE_AFTER = 100;
public static bool $disable_completely = false;
/** @var integer */ /** @var integer */
private int $_verbosity = 0; private int $_verbosity = 0;
/** @var string */ /** @var string */
@ -126,6 +128,8 @@ final class MDOutputHandler {
*/ */
public function toLog(string $msg, MDConsoleStatus $statusCode = MDConsoleStatus::NOTICE):void { public function toLog(string $msg, MDConsoleStatus $statusCode = MDConsoleStatus::NOTICE):void {
if (self::$disable_completely === true) return;
// Get parts for generating the message to log. // Get parts for generating the message to log.
++$this->_counter; // Increment counter ++$this->_counter; // Increment counter
$date = \date("Y-m-d H:i:s"); // Get current date & time. $date = \date("Y-m-d H:i:s"); // Get current date & time.
@ -184,6 +188,11 @@ final class MDOutputHandler {
*/ */
public function __destruct() { public function __destruct() {
if (self::$disable_completely === true) return;
echo $this->_verbosity;
if ($this->_verbosity < 0) return;
if (!empty($this->_log_queue)) { if (!empty($this->_log_queue)) {
$this->flush_to_logfile(); $this->flush_to_logfile();
} }