<?php
Function error_handler($error,$message,$file,$line)
{
if($error & error_reporting())
{
$log=array();
switch($error)
{
case E_ERROR:
$type='FATAL';
break;
case E_WARNING:
$type='ERROR';
break;
case E_NOTICE:
$type='WARNING';
break;
default:
$type='Unknown error type ['.$error.']';
break;
}
$log[]=$type.': '.$message.' in line '.$line.' of file '.$file.', PHP '.PHP_VERSION.' ('.PHP_OS.')';
if(function_exists('debug_backtrace'))
{
$backtrace=debug_backtrace();
for($level=1;$level<count($backtrace);$level++)
{
$message='File: '.$backtrace[$level]['file'].' Line: '.$backtrace[$level]['line'].' Function: ';
if(IsSet($backtrace[$level]['class']))
$message.='(class '.$backtrace[$level]['class'].') ';
if(IsSet($backtrace[$level]['type']))
$message.=$backtrace[$level]['type'].' ';
$message.=$backtrace[$level]['function'].'(';
if(IsSet($backtrace[$level]['args']))
{
for($argument=0;$argument<count($backtrace[$level]['args']);$argument++)
{
if($argument>0)
$message.=', ';
$message.=serialize($backtrace[$level]['args'][$argument]);
}
}
$message.=')';
$log[]=$message;
}
}
error_log(implode("\n\t",$log));
}
if($type==E_ERROR)
exit(1);
}
set_error_handler('error_handler');
?>
|