1
0
mirror of https://github.com/Chouchen/shorturl.git synced 2018-06-07 06:34:38 +02:00
shorturl/class/log.php

30 lines
715 B
PHP
Raw Normal View History

2010-12-23 12:26:25 +01:00
<?
class Log {
protected $logfile;
function __construct($filename) {
$file = $filename;
$this->logfile = fopen($file, 'a+');
$this->message('Starting log');
}
function message($message) {
$message = '['. date("Y-m-d / H:i:s") . '] @MESSAGE'.' - '.$message;
$message .= "\n";
return fwrite( $this->logfile, $message );
}
function error($message) {
$message = '['. date("Y-m-d / H:i:s") . '] @ERROR'.' - '.$message;
$message .= "\n";
return fwrite( $this->logfile, $message );
}
function __destruct(){
$this->message("Finishing log\n-----------------------");
return fclose( $this->logfile );
}
}