Skip to content

Instantly share code, notes, and snippets.

@adamlutz
Created October 24, 2013 18:43
Show Gist options
  • Save adamlutz/7142751 to your computer and use it in GitHub Desktop.
Save adamlutz/7142751 to your computer and use it in GitHub Desktop.
function debug_string_backtrace() {
$output = '';
$backtrace = debug_backtrace();
foreach($backtrace as $key => $item) {
$output .= "\r\n item $key ".$item['file']." [".$item['line']."] ".$item['function'];
}
return $output;
}
error_reporting(E_ERROR);
function fatal_handler() {
// $errfile = "unknown file";
// $errstr = "shutdown";
// $errno = E_CORE_ERROR;
// $errline = 0;
$error = error_get_last();
if( $error !== NULL && $error['type'] == E_ERROR) {
$errno = $error["type"];
$errfile = $error["file"];
$errline = $error["line"];
$errstr = $error["message"];
error_log("TRAPPED --> $errno $errfile $errline $errstr");
error_log( debug_string_backtrace() ); //
// error_log( implode(" ** ", debug_backtrace( false )) );
}
//exit(0);
//error_mail( format_error( $errno, $errstr, $errfile, $errline ) );
}
register_shutdown_function( "fatal_handler" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment