This is a discussion on Handling the error_handler within the PHP Language forums, part of the PHP Programming Forums category; I've recently been looking into PHP's custom error handler support, which seems to me to fail at exactly ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've recently been looking into PHP's custom error handler support,
which seems to me to fail at exactly the point that you need it to start working. I quote: "Note: The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and E_COMPILE_WARNING." -- from http://au.php.net/manual/en/function...or-handler.php How do I get PHP to email me when a *genuinely serious* error occurs? Those, after all, are the ones that I really want to be told about. Is there the PHP equivalent of an 'onAbort' hook anywhere? Basically, I want to know what's gone wrong when it happens, rather than needing to look through logfiles to see what went wrong in the past. How do people normally do this? Nigel Chapman, Sydney Australia. kale77in at hotmail * (don't reply to my [From:] address, it's bogus) |
|
|||
|
"Nigel A. Chapman" <nchapman@bigpond.com> writes:
> How do I get PHP to email me when a *genuinely serious* error occurs? > Those, after all, are the ones that I really want to be told about. > Is there the PHP equivalent of an 'onAbort' hook anywhere? > > Basically, I want to know what's gone wrong when it happens, rather > than needing to look through logfiles to see what went wrong in the > past. > > How do people normally do this? I have PHP set up to send its error messages through syslog to /var/log/user.log Then, I run the logcheck program hourly from cron, and get the error messages emailed to me if any happened since the last run. If you really needed almost instant notification, you could run logcheck every five minutes - it's fairly lightweight. Logcheck lets you set up a lot of good filtering so you only get interesting stuff. I'd recommend using it in combination with a good syslog program such as syslog-ng to make filtering easier. -- Chris |
|
|||
|
Thanks, that's helpful. I'll fall back to that position unless I can
find something that doesn't require access to the server. Chris Morris wrote: > I have PHP set up to send its error messages through syslog to > /var/log/user.log > > Then, I run the logcheck program hourly from cron, and get the > error messages emailed to me if any happened since the last run. > > If you really needed almost instant notification, you could run > logcheck every five minutes - it's fairly lightweight. > > Logcheck lets you set up a lot of good filtering so you only get > interesting stuff. I'd recommend using it in combination with a good > syslog program such as syslog-ng to make filtering easier. |
|
|||
|
Tony Marston wrote:
>>"Note: The following error types cannot be handled with a user defined >>function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, >>E_COMPILE_ERROR and E_COMPILE_WARNING." > Take a look at http://www.tonymarston.net/php-mysql/errorhandler.html > which shows you how to create an error handler which will send an > email if a fatal error is encountered. I'll give it a run, but I don't see from your code how your user-defined-error function gets around the above-mentioned limitation in PHP. Does it really respond to parsing errors? -- Nigel Chapman, Sydney Australia. kale77in at hotmail * (don't reply to my [From:] address, it's bogus) |
|
|||
|
"Nigel A. Chapman" <nchapman@bigpond.com> wrote in message news:<p87Ua.13944$OM3.8867@news-server.bigpond.net.au>...
> Tony Marston wrote: > > >>"Note: The following error types cannot be handled with a user defined > >>function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, > >>E_COMPILE_ERROR and E_COMPILE_WARNING." > > > Take a look at http://www.tonymarston.net/php-mysql/errorhandler.html > > which shows you how to create an error handler which will send an > > email if a fatal error is encountered. > > I'll give it a run, but I don't see from your code how your > user-defined-error function gets around the above-mentioned limitation > in PHP. Does it really respond to parsing errors? No. If a parsing error occurs then your script won't even run (this will be detected when you test your script). My error handler will trap runtime errors. Try using it, and force a few runtime errors just to see what happens. Tony Marston http://www.tonymarston.net/ |