Source for file logs.class.php
Documentation is available at logs.class.php
define('ICQBOT_DEFAULTLOGDIR','./store/logs/');
define('LOGLEVEL_NONE',LOGLEVEL_0);
define('LOGLEVEL_GENERAL',LOGLEVEL_1);
define('LOGLEVEL_DEFAULT',LOGLEVEL_GENERAL);
private $fp_customs; // array( file_name => file_resource, ... );
public function __construct($logdir = ICQBOT_DEFAULTLOGDIR)
$this->logdir = $logdir; // ? $logdir : ICQBOT_DEFAULTLOGDIR;
$this->fp_log= fopen($this->logdir. '/icqbot.log','a');
fputs($this->fp_log,"\r\n");
echo 'Log directory "'. $this->logdir. '" is not writable! Logs will be unavailable.';
$this->fp_customs = array();
public function write($msg, $loglevel = LOGLEVEL_DEFAULT, $timeformat = '[r]', $custom_file = '')
if ($this->loglevel < $loglevel)
return $this->writeFile($msg, $timeformat, $custom_file);
echo ($timeformat ? date($timeformat). ' ' : ''). $msg. "\r\n";
return fputs($this->fp_log, ($timeformat ? date($timeformat). ' ' : ''). $msg. "\r\n");
private function writeFile($msg, $timeformat, $custom_file)
$this->fp_customs[$custom_file] = @fopen($this->logdir. $custom_file,"a");
if (!$this->fp_customs[$custom_file])
$this->write('Custom logfile "'. $custom_file. '" is not writable. Logs will be written here.');
$this->fp_customs[$custom_file] = &$this->fp_log;
if (!$this->fp_customs[$custom_file])
if ($this->fp_customs[$custom_file] == $this->fp_log)
$msg= '{'. $custom_file. '} '. $msg;
return fputs($this->fp_customs[$custom_file], ($timeformat ? date($timeformat). ' ' : ''). $msg. "\r\n");
foreach ($this->fp_customs as $v)
|