create array, remove getConstants function, add self references.
pull/6046/head
Adam Magness 2018-10-30 11:40:11 -04:00
rodzic 342e484533
commit 17ae53c9d7
1 zmienionych plików z 10 dodań i 29 usunięć

Wyświetl plik

@ -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 == '')