Created
August 10, 2017 07:05
-
-
Save Nikki0/b395a36454291aab7ca0fd731f9746fe to your computer and use it in GitHub Desktop.
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
<?php error_reporting(0); | |
$old_error_handler = set_error_handler("userErrorHandler"); | |
function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars) | |
{ | |
$time=date("d M Y H:i:s"); | |
// Get the error type from the error number | |
$errortype = array (1 => "Error", | |
2 => "Warning", | |
4 => "Parsing Error", | |
8 => "Notice", | |
16 => "Core Error", | |
32 => "Core Warning", | |
64 => "Compile Error", | |
128 => "Compile Warning", | |
256 => "User Error", | |
512 => "User Warning", | |
1024 => "User Notice"); | |
$errlevel=$errortype[$errno]; | |
//Write error to log file (CSV format) | |
$errfile=fopen("errors.csv","a"); | |
fputs($errfile,"\"$time\",\"$filename: | |
$linenum\",\"($errlevel) $errmsg\"\r\n"); | |
fclose($errfile); | |
if($errno!=2 && $errno!=8) { | |
//Terminate script if fatal error | |
die("A fatal error has occurred. Script execution has been aborted"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment