lordvader Posted April 11, 2008 Share Posted April 11, 2008 Hi, I'm using this nifty error logging script http://programmabilities.com/php/?id=5 which outputs errors to a file of my choosing (my host doesn't allow me access to the standard error file). Anyways, I've been trying to get it to log 'Fatal error: Call to undefined function' errors, but it won't. Are those errors loggable? And if so, what am I missing? Here's the code if you don't want to visit the link: <?php /* we will do our own error handling. */ error_reporting(0); // Turns off all error reporting. /* user defined error handling function */ function userErrorHandler($errno, $errmsg, $filename, $linenum, $vars) { // timestamp for the error entry $dt = date('Y-m-d H:i:s (T)'); // define an assoc array of error string // in reality the only entries we should // consider are E_WARNING, E_NOTICE, E_USER_ERROR, // E_USER_WARNING and E_USER_NOTICE $errortype = array ( E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice' ); // set of errors for which a var trace will be saved $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); $err = "<errorentry>\n"; $err .= "\t<datetime>" .$dt. "</datetime>\n"; $err .= "\t<errornum>" .$errno. "</errornum>\n"; $err .= "\t<errortype>" .$errortype[$errno]. "</errortype>\n"; $err .= "\t<errormsg>" .$errmsg. "</errormsg>\n"; $err .= "\t<scriptname>" .$filename. "</scriptname>\n"; $err .= "\t<scriptlinenum>" .$linenum. "</scriptlinenum>\n"; if (in_array($errno, $user_errors)) { $err .="\t<vartrace>".wddx_serialize_value($vars,'Variables')."</vartrace>\n"; } $err .= "</errorentry>\n\n"; // save to the error log file, and e-mail me if there is a critical user error. error_log($err, 3, '../error_log.log'); if ($errno == E_USER_ERROR) { mail('[email protected]', 'Critical User Error', $err); } } $old_error_handler = set_error_handler('userErrorHandler'); ?> TIA Link to comment https://forums.phpfreaks.com/topic/100737-trying-to-log-fatal-error-call-to-undefined-function-errors-but-cant/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 11, 2008 Share Posted April 11, 2008 Fatal parse errors occur and stop the parser before your code ever runs, so nothing you do in your code with an error handler will ever show fatal parse errors. If you are receiving fatal parse errors, it means the syntax is incorrect. You should be debugging your code on a local development computer to the point that it is error free, before you put it onto a live server. You can also turn on the display_errors setting and set the error_reporting level in a .htaccess file (when php is running as an Apache server module) or in a local php.ini (when php is running as a cgi wrapper) to get php to display fatal parse errors if you need the live server to do this. Link to comment https://forums.phpfreaks.com/topic/100737-trying-to-log-fatal-error-call-to-undefined-function-errors-but-cant/#findComment-515257 Share on other sites More sharing options...
lordvader Posted April 12, 2008 Author Share Posted April 12, 2008 Thanks for the info, very helpful. Link to comment https://forums.phpfreaks.com/topic/100737-trying-to-log-fatal-error-call-to-undefined-function-errors-but-cant/#findComment-515308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.