Handling the error_handler

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-19-2003
Nigel A. Chapman
 
Posts: n/a
Default Handling the error_handler

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)

Reply With Quote
  #2 (permalink)  
Old 07-20-2003
Chris Morris
 
Posts: n/a
Default Re: Handling the error_handler

"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
Reply With Quote
  #3 (permalink)  
Old 07-25-2003
Nigel A. Chapman
 
Posts: n/a
Default Re: Handling the error_handler

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.


Reply With Quote
  #4 (permalink)  
Old 07-25-2003
Nigel A. Chapman
 
Posts: n/a
Default Re: Handling the error_handler

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)

Reply With Quote
  #5 (permalink)  
Old 07-25-2003
Tony Marston
 
Posts: n/a
Default Re: Handling the error_handler

"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/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0