From 17ae53c9d7c3e1a4ccddb0c99769df8e2835d4ce Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Tue, 30 Oct 2018 11:40:11 -0400 Subject: [PATCH] Review Updates create array, remove getConstants function, add self references. --- src/Core/Logger.php | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/Core/Logger.php b/src/Core/Logger.php index 0a6e560206..c9253a83e9 100644 --- a/src/Core/Logger.php +++ b/src/Core/Logger.php @@ -22,16 +22,14 @@ class Logger extends BaseObject const DATA = 4; const ALL = 5; - public static $levels = []; - - /** - * @brief Get class constants, and avoid using substring. - */ - public static function getConstants() - { - $reflectionClass = new ReflectionClass(__CLASS__); - return $reflectionClass->getConstants(); - } + public static $levels = [ + self::WARNING => 'Warning', + self::INFO => 'Info', + self::TRACE => 'Trace', + self::DEBUG => 'Debug', + self::DATA => 'Data', + self::ALL => 'All', + ]; /** * @brief Logs the given message at the given log level @@ -55,14 +53,6 @@ class Logger extends BaseObject return; } - if (count(self::$levels) == 0) - { - foreach (self::getConstants() as $k => $v) - { - $levels[$v] = $k; - } - } - $processId = session_id(); if ($processId == '') @@ -81,7 +71,7 @@ class Logger extends BaseObject $logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n", DateTimeFormat::utcNow(DateTimeFormat::ATOM), $processId, - $levels[$level], + self::$levels[$level], basename($callers[0]['file']), $callers[0]['line'], $function, @@ -100,9 +90,8 @@ class Logger extends BaseObject * personally without background noise * * @param string $msg - * @param int $level */ - public static function devLog($msg, $level = self::INFO) + public static function devLog($msg) { $a = self::getApp(); @@ -119,14 +108,6 @@ class Logger extends BaseObject return; } - if (count(self::$levels) == 0) - { - foreach (self::getConstants() as $k => $v) - { - $levels[$v] = $k; - } - } - $processId = session_id(); if ($processId == '') -- 2.39.5