<?php
class Errorlog extends Exception
{
private $errlog_path="log4thumb";
function __construct()
{
//$errorMsg =date('F, d M Y H:i:s')." : ";
//$str =$errorMsg .=$str." ";
//$fileName = $this->getFile();
//$str .="File : ".$fileName. " ".$this->getMessage(). " @Line " .$this->getLine();
//$doc_root = $_SERVER['DOCUMENT_ROOT'];
if(!file_exists($this->errlog_path))
{
if(!mkdir($this->errlog_path))
{
print "Create a directory named \"log4thumb\" and set it to write permission";
exit;
}
chmod($this->errlog_path,0777);
}
if(!file_exists($this->errlog_path."/".Date('d-m-Y').'.txt')){
$ourFileName = $this->errlog_path."/".Date('d-m-Y').'.txt';
$ourFileHandle = fopen($ourFileName, 'w') or die("can't oxxpen file");
fclose($ourFileHandle);
chmod($ourFileName,0777);
}
//error_log($str."\n",3,$ourFileName);
//}else{
//error_log($str."\n",3,$errlog_path.Date('d-m-Y').".txt");
//}
}
function writeLog($msg)
{
$errorMsg =date('F, d Y H:i:s')." : ";
$errorMsg .=$msg." ";
$str = $errorMsg;
//$doc_root = $_SERVER['DOCUMENT_ROOT'];
//$errlog_path =$doc_root."/subashps/RD/dbexport/log/";
if(!file_exists($this->errlog_path."/".Date('d-m-Y').'.txt')){
$ourFileName = $this->errlog_path."/".Date('d-m-Y').'.txt';
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open123 file");
fclose($ourFileHandle);
chmod($ourFileName,0777);
error_log($str."\n",3,$ourFileName);
}else{
error_log($str."\n",3,$this->errlog_path."/".Date('d-m-Y').".txt");
}
}
}
?>