From MWWiki
Back to Main Project Page
<?php
/**
* Handles some of the more menial tasks of logging.
*
*/
class Logger {
/** logging levels */
public static $INFO = 'NOTICE';
public static $WARN = 'WARNING';
public static $ERROR = 'ERROR';
/** file descriptor */
private $fp;
public function __construct($logfile) {
$this->fp = @fopen($logfile, "a+");
// ERROR HANDLING?
}
public function __destruct() {
fclose($this->fp);
}
public function write($msg, $level) {
if ($this->fp) {
$timestamp = date('Y-m-d H:i:s');
fwrite($this->fp, $timestamp . ' :: ' . $level .
' :: ' . $msg . "\n");
}
}
}
?>