Error reporting

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Any ideas how to make a email report of all the error messages?

I've read on how to do it the problem is that it sends a email
for each error instead of sending a single email with all the errors.

The code I have thus far (sams as less a few lines I didnt

// 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");

   // define an assoc array of error string
   // in reality the only entries we should
   // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
   $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",
   // set of errors for which a var trace will be saved
   $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);

   $err = "<table><tr>";
   $err .= "<td>" . $dt . "</td>";
   $err .= "<td>" . $errmsg . "</td>";
   $err .= "<td>" . $linenum . "</td></tr></table>";

   if (in_array($errno, $user_errors)) {
       $err .= "\t<vartrace>" . wddx_serialize_value($vars,
"Variables") . "</vartrace>\n";
   $err .= "</errorentry>\n\n";
   // for testing
   echo $err;

Re: Error reporting wrote:

Quoted text here. Click to load it

If you implement your error handler in the same PHP thread as the code
throwing the error you'll never have visibility of fatal errors. A better
solution is to configure PHP to log its errors properly then read the log
file. If you don't have access to the config/logfile then your only option
is the error handler route - write your own error handler and set it to
send the file (and reset it) at intervals.


Site Timeline