Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Error reporting from web/mail scripts.

by btrott (Parson)
on Aug 26, 2001 at 22:28 UTC ( #107964=note: print w/replies, xml ) Need Help??

in reply to Error reporting from web/mail scripts.

You say:
> When you put a web CGI script or an email processing > script or a cron-run script into production, you can't use > the standard die and warn functions to get errors because > the standard error stream goes to some random place.
No, it goes to the webserver error log. I wouldn't call it a random place, necessarily. :) In my opinion, that's where it *should* go; in a production system it certainly shouldn't be sent to the browser, because that could reveal sensitive information and introduce a security hole.

carp and croak aren't really going to help you here. They write to STDERR just like die and warn do. The difference is that they report errors from the perspective of the caller.

You *can*, however, use CGI::Carp. This lets you use a carpout function to write error messages to a different filehandle than STDERR. From the docs:

BEGIN { use CGI::Carp qw(carpout); open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or die("Unable to open mycgi-log: $!\n"); carpout(LOG); }
However, the docs do say that using carpout is a hit on performance, so it is recommended for development usage only.

If you would like to capture errors and have them sent as email messages to you, you could use a $SIG{__DIE__} handler, or you could wrap your script in an eval to catch errors; if an error occurs, send yourself email with the error message.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://107964]
[talexb]: TStanley I'm flying to Vegas in two weeks time. After that flights leaving Vegas and Phoenix are late at night .. I've been hearing that it gets so hot that the air isn't dense enough for planes to take off. Weird. Guess you won't have that problem.
[Corion]: Yay, vacation time now - one week off work (but a Perl workshop in the middle ;)) )
[talexb]: TStanley I just realized that I was in your area for a convention back in April. We were at the high school for the weekend, the one with the long driveway. Nice spot.
[TStanley]: I am heading to Arlington, Virginia next week, then I get to spend an entire week at home. Looking forward to that as I will have spent 7 weeks on the road by the end of next week

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2017-06-23 14:19 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (548 votes). Check out past polls.