Last active
December 22, 2015 17:29
-
-
Save uabassguy/6506245 to your computer and use it in GitHub Desktop.
Custom error handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function custom_error_debug($errno, $errstr, $errfile, $errline, $errvars) { | |
$message = ""; | |
$message .= "[ " . date('Y-m-d h-i-s') . " ] Error: [$errno] $errstr on line $errline of $errfile "; | |
//Dump all info to browser! | |
//WARNING: Leave this commented except for extreme cases where you need to see all variables in use! | |
//Using this will cause excessive processing time, and RAM. Use only as needed! | |
/*if (!empty($errvars)) { | |
echo $message . PHP_EOL . "Variables in use: <pre>";print_r($errvars); echo "</pre>"; | |
//WARNING: not ending execution here may cause the browser to overload on larger frameworks, comment out at your own risk! | |
die(); | |
}*/ | |
//get the directory of the offending file, put a log in that path, and separate them by end of line, append to file | |
file_put_contents ( dirname($errfile) . "/php_errors.log", $message . PHP_EOL, FILE_APPEND ); | |
//Dump all variables to file as well, (MAY CAUSE LARGE FILES, read above) | |
//file_put_contents ( dirname($errfile) . "/php_errors.log", $errvars . PHP_EOL, FILE_APPEND ); | |
//Optionally end script execution | |
//die(); | |
} | |
set_error_handler('custom_error_debug'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment