Commit 5abc35f8a369d43d36cc8409cd351a0ad2fa219b
1 parent
e883d64b
refactored prefixing logging strings
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@307 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
11 additions
and
7 deletions
lib/Log.inc
| ... | ... | @@ -48,9 +48,7 @@ class Log { |
| 48 | 48 | * @param $logEntry the message to write to the log file |
| 49 | 49 | */ |
| 50 | 50 | function debug($logEntry) { |
| 51 | - // prefix entry | |
| 52 | - $logEntry = date("Y-m-d H:i:s",time()) . ":DEBUG:" . $logEntry . "\n"; | |
| 53 | - $this->writeLog($logEntry, DEBUG); | |
| 51 | + $this->writeLog($this->prefixEntry($logEntry, "DEBUG"), DEBUG); | |
| 54 | 52 | } |
| 55 | 53 | |
| 56 | 54 | /** |
| ... | ... | @@ -59,8 +57,7 @@ class Log { |
| 59 | 57 | * @param $logEntry the message to write to the log file |
| 60 | 58 | */ |
| 61 | 59 | function info($logEntry) { |
| 62 | - $logEntry = date("Y-m-d H:i:s",time()) . ":INFO:" . $logEntry . "\n"; | |
| 63 | - $this->writeLog($logEntry, INFO); | |
| 60 | + $this->writeLog($this->prefixEntry($logEntry, " INFO"), INFO); | |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | /** |
| ... | ... | @@ -69,8 +66,7 @@ class Log { |
| 69 | 66 | * @param $logEntry the message to write to the log file |
| 70 | 67 | */ |
| 71 | 68 | function error($logEntry) { |
| 72 | - $logEntry = date("Y-m-d H:i:s",time()) . ":ERROR:" . $logEntry . "\n"; | |
| 73 | - $this->writeLog($logEntry, ERROR); | |
| 69 | + $this->writeLog($this->prefixEntry($logEntry, "ERROR"), ERROR); | |
| 74 | 70 | } |
| 75 | 71 | |
| 76 | 72 | /** |
| ... | ... | @@ -88,5 +84,13 @@ class Log { |
| 88 | 84 | fclose($fp); |
| 89 | 85 | } |
| 90 | 86 | } |
| 87 | + | |
| 88 | + /** | |
| 89 | + * Prefixes the log entry with the current date time, the logging level | |
| 90 | + * and the page that called it | |
| 91 | + */ | |
| 92 | + function prefixEntry($logEntry, $logLevel) { | |
| 93 | + return getCurrentDateTime() . ":$logLevel: $logEntry\n"; | |
| 94 | + } | |
| 91 | 95 | } |
| 92 | 96 | ?> | ... | ... |