From 27431ef0a0c9227f7ade140591e845b1d3dd57d7 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sat, 8 Aug 2020 22:23:27 +0200 Subject: [PATCH] Use class constants from MDConsole to MDOutputHandler --- src/MDConsole.php | 8 ++------ src/MDOutputHandler.php | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/MDConsole.php b/src/MDConsole.php index 8cd661b..15dee7b 100644 --- a/src/MDConsole.php +++ b/src/MDConsole.php @@ -14,7 +14,7 @@ class MDConsole { const STATUS_UPDATE = 1; const STATUS_DELETION = 2; const STATUS_ERROR = 3; - const STATUS_SKIPPED = 3; + const STATUS_SKIPPED = 4; const CONSOLE_LEVEL_COLORS = [ self::STATUS_NOTICE => "", @@ -115,11 +115,7 @@ class MDConsole { if ($duration < 30) return; - toNote("Long script run", round($duration, 2), "Script run time, that's: "); - toNote("Long script run", memory_get_peak_usage(), "Peak memory usage"); - toNote("Long script run", memory_get_usage(), "Memory usage at end of script"); - - # print_r($GLOBALS); + self::note("Long script run" . PHP_EOL . "Script run time, that's: " . round($duration, 2) . PHP_EOL . "Peak memory usage: " . memory_get_peak_usage() . PHP_EOL . "Memory usage at end of script: " . memory_get_usage()); }, $startTime); } diff --git a/src/MDOutputHandler.php b/src/MDOutputHandler.php index d5f5279..397c0f2 100644 --- a/src/MDOutputHandler.php +++ b/src/MDOutputHandler.php @@ -51,7 +51,7 @@ class MDOutputHandler { * * @return void */ - public function setVerbosity(int $input = 0) { + final public function setVerbosity(int $input = 0):void { $this->_verbosity = $input; @@ -64,7 +64,7 @@ class MDOutputHandler { * * @return void */ - public function setContext(string $input = "") { + final public function setContext(string $input = ""):void { $this->_context = $input; @@ -77,7 +77,7 @@ class MDOutputHandler { * * @return void */ - public function setFileLogging(bool $input = false) { + final public function setFileLogging(bool $input = false):void { $this->_file_logging = $input; @@ -101,23 +101,26 @@ class MDOutputHandler { * * @return void */ - public function toLog(string $msg, int $statusCode = 0) { + final public function toLog(string $msg, int $statusCode = 0):void { // Get parts for generating the message to log. $this->_counter++; // Increment counter $date = date("Y-m-d H:i:s"); // Get current date & time. switch ($statusCode) { - case 1: + case MDConsole::STATUS_SKIPPED: $statusSymbol = "-"; break; - case 2: + case MDConsole::STATUS_UPDATE: $statusSymbol = "U"; break; - case 3: + case MDConsole::STATUS_ERROR: $statusSymbol = "E"; break; - case 0: + case MDConsole::STATUS_DELETION: + $statusSymbol = "D"; + break; + case MDConsole::STATUS_NOTICE: default: $statusSymbol = "N"; break; @@ -145,7 +148,7 @@ class MDOutputHandler { /** * Constructor function that sets defaults and ensures the logfile exists. */ - function __construct() { + public function __construct() { $this->_startTime = microtime(true); $this->_counter = 0;