Exemplo n.º 1
0
			}
		}
		
		public  function writeLog($message)
		{
			$ip =  isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0';
			$debug = debug_backtrace(true);
			$string = date('Y-m-d H:i:s')."\t";
			$string .= $ip."\t";
			$string .=$debug[0]['file']."\t";
			$string .= "\tline" . $debug[0]['line']."\t";
			$string .= json_encode($message)."\r\n";
			if(!fwrite($this->fileHander, $string)){
				die('the log file can not be written!');
			}
		}
		
		public function __destruct()
		{
			if($this->fileHander!=null){
				fclose($this->fileHander);
			}
		}
		
	}
	
	$log = new Lib_Log();
	$log->writeLog('the error debug!');
	echo "</pre>";
	
?>