Error reporting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scuniverse@gmail.com

    Error reporting

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

    I've read on php.net 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 php.net less a few lines I didnt
    need):

    // user defined error handling function
    function userErrorHandle r($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,
    // 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_WARNI NG => "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_ER ROR, 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($errn o, $user_errors)) {
    $err .= "\t<vartrac e>" . wddx_serialize_ value($vars,
    "Variables" ) . "</vartrace>\n";
    }
    $err .= "</errorentry>\n\n ";

    // for testing
    echo $err;
    }

  • Colin McKinnon

    #2
    Re: Error reporting

    scuniverse@gmai l.com wrote:
    [color=blue]
    > Any ideas how to make a email report of all the error messages?
    >
    > I've read on php.net 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.
    >[/color]

    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.

    C.

    Comment

    Working...