diff --git a/log/error_handler/error_handler_jsonoutput.php b/log/error_handler/error_handler_jsonoutput.php index d2af125..89112ea 100644 --- a/log/error_handler/error_handler_jsonoutput.php +++ b/log/error_handler/error_handler_jsonoutput.php @@ -10,7 +10,7 @@ class error_handler_jsonoutput extends \SYSTEM\LOG\error_handler { try{ echo \SYSTEM\LOG\JsonResult::error($E); } catch (\Exception $E){} //Error -> Ignore - return true; + return die(); //die is required cuz else some fatals cant be catched properly } } } \ No newline at end of file diff --git a/log/exceptions/ErrorException.php b/log/exceptions/ErrorException.php new file mode 100644 index 0000000..1e835a7 --- /dev/null +++ b/log/exceptions/ErrorException.php @@ -0,0 +1,10 @@ +'); + ini_set('error_append_string', ''); + ob_start('\SYSTEM\LOG\log::__fatal_error_handler'); } private static function call_handlers(\Exception $E, $thrown = true){ @@ -27,17 +34,29 @@ class log { return true;} } return false; - } + } public static function __exception_handler(\Exception $E, $thrown = true){ return self::call_handlers($E, $thrown) && $thrown;} public static function __error_handler($code, $message, $file, $line, $thrown = true){ - return self::call_handlers(new \ErrorException($message, 1, $code, $file, $line) ,$thrown);} + return self::call_handlers(new \SYSTEM\LOG\ErrorException($message, 1, $code, $file, $line) ,$thrown);} - public static function __shutdown_handler($thrown = true) { + public static function __shutdown_handler($thrown = true) { if( ($error = error_get_last()) !== NULL && !$error['type'] === E_DEPRECATED) { //http://www.dreamincode.net/forums/topic/284506-having-trouble-supressing-magic-quotes-gpc-fatal-errors/ - return self::call_handlers(new \ErrorException($error["message"], 1, $error["type"],$error["file"],$error["line"]) ,$thrown);} + return self::call_handlers(new \SYSTEM\LOG\ShutdownException($error["message"], 1, $error["type"],$error["file"],$error["line"]) ,$thrown);} } + + public static function __fatal_error_handler($bufferContent, $thrown = true){ + $errors = array(); + if ( preg_match('|.*|s', $bufferContent, &$errors) ){ + $error = strip_tags($errors[0]); + $error = substr($error,1,strlen($error)-2); + $file = substr($error,strpos($error,' in ')+5,strpos($error,' on ')-5-strpos($error,' in ')); + $line = intval(substr($error,strpos($error,' line ')+6)); + $error = substr($error,0,strpos($error,' in ')); + return \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\ShutdownException($error,1,1,$file,$line));} + return $bufferContent; + } } diff --git a/log/register_errorhandler_dbwriter.php b/log/register_errorhandler_dbwriter.php deleted file mode 100644 index 2ec74c8..0000000 --- a/log/register_errorhandler_dbwriter.php +++ /dev/null @@ -1,2 +0,0 @@ -