From 5abc35f8a369d43d36cc8409cd351a0ad2fa219b Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Fri, 17 Jan 2003 10:58:37 +0000 Subject: [PATCH] refactored prefixing logging strings --- lib/Log.inc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Log.inc b/lib/Log.inc index da4a237..76fac7f 100644 --- a/lib/Log.inc +++ b/lib/Log.inc @@ -48,9 +48,7 @@ class Log { * @param $logEntry the message to write to the log file */ function debug($logEntry) { - // prefix entry - $logEntry = date("Y-m-d H:i:s",time()) . ":DEBUG:" . $logEntry . "\n"; - $this->writeLog($logEntry, DEBUG); + $this->writeLog($this->prefixEntry($logEntry, "DEBUG"), DEBUG); } /** @@ -59,8 +57,7 @@ class Log { * @param $logEntry the message to write to the log file */ function info($logEntry) { - $logEntry = date("Y-m-d H:i:s",time()) . ":INFO:" . $logEntry . "\n"; - $this->writeLog($logEntry, INFO); + $this->writeLog($this->prefixEntry($logEntry, " INFO"), INFO); } /** @@ -69,8 +66,7 @@ class Log { * @param $logEntry the message to write to the log file */ function error($logEntry) { - $logEntry = date("Y-m-d H:i:s",time()) . ":ERROR:" . $logEntry . "\n"; - $this->writeLog($logEntry, ERROR); + $this->writeLog($this->prefixEntry($logEntry, "ERROR"), ERROR); } /** @@ -88,5 +84,13 @@ class Log { fclose($fp); } } + + /** + * Prefixes the log entry with the current date time, the logging level + * and the page that called it + */ + function prefixEntry($logEntry, $logLevel) { + return getCurrentDateTime() . ":$logLevel: $logEntry\n"; + } } ?> -- libgit2 0.21.4