1 |
<? |
2 |
// --------------------------------------------------------------------------- |
3 |
// $Id: Logger.php,v 1.1 2003/02/03 03:33:48 joko Exp $ |
4 |
// --------------------------------------------------------------------------- |
5 |
// $Log: Logger.php,v $ |
6 |
// Revision 1.1 2003/02/03 03:33:48 joko |
7 |
// + initial commit |
8 |
// |
9 |
// --------------------------------------------------------------------------- |
10 |
|
11 |
|
12 |
class DesignPattern_Logger { |
13 |
|
14 |
var $logger; |
15 |
var $logfile; |
16 |
var $enabled; |
17 |
|
18 |
function constructor() { |
19 |
// FIXME: this is hardcoded! |
20 |
$this->_init_logger("../core/var/log/logfile.txt", 1); |
21 |
} |
22 |
|
23 |
function log($msg, $level) { |
24 |
//print "log: $msg<br>"; |
25 |
if ($this->logger) { |
26 |
$this->logger->log($msg, $level); |
27 |
} else { |
28 |
// TODO: how are these type of errors handled? |
29 |
//print "error-message: $msg<br>"; |
30 |
} |
31 |
} |
32 |
|
33 |
function _init_logger($logfile, $enable = 0) { |
34 |
$this->logfile = $logfile; |
35 |
$this->enabled = $enable; |
36 |
//print Dumper($this); |
37 |
$this->_init_Log_singleton(); |
38 |
} |
39 |
|
40 |
function _init_Log_singleton() { |
41 |
// Log |
42 |
// valid logging-levels are: |
43 |
// LOG_EMERG, LOG_ALERT, LOG_CRIT, |
44 |
// LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG. |
45 |
// The default is LOG_INFO. |
46 |
// $logfile = 'log.txt'; |
47 |
// $logfile = $this->config[path][base] . "core/var/log/logfile.txt"; |
48 |
|
49 |
// TODO: maybe include userid here? |
50 |
//$log_ident = substr(session_id(), 10, 6); |
51 |
$log_ident = session_id(); |
52 |
$outkey = 'dummy'; |
53 |
if ($this->enabled) { |
54 |
$outkey = 'file'; |
55 |
} |
56 |
$this->logger = &Log::singleton($outkey, $this->logfile, $log_ident); |
57 |
//$this->log( get_class($this) . "->_init_logger: ready\t\t--------------------", LOG_DEBUG ); |
58 |
} |
59 |
|
60 |
} |
61 |
|
62 |
?> |