Parent Directory
|
Revision Log
1.27
| 1 | wakaba | 1.1 | package CGI::Carp; |
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | B<CGI::Carp> - CGI routines for writing to the HTTPD (or other) error log | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use CGI::Carp; | ||
| 10 | |||
| 11 | croak "We're outta here!"; | ||
| 12 | confess "It was my fault: $!"; | ||
| 13 | carp "It was your fault!"; | ||
| 14 | warn "I'm confused"; | ||
| 15 | die "I'm dying.\n"; | ||
| 16 | |||
| 17 | use CGI::Carp qw(cluck); | ||
| 18 | cluck "I wouldn't do that if I were you"; | ||
| 19 | |||
| 20 | use CGI::Carp qw(fatalsToBrowser); | ||
| 21 | die "Fatal error messages are now sent to browser"; | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | CGI scripts have a nasty habit of leaving warning messages in the error | ||
| 26 | logs that are neither time stamped nor fully identified. Tracking down | ||
| 27 | the script that caused the error is a pain. This fixes that. Replace | ||
| 28 | the usual | ||
| 29 | |||
| 30 | use Carp; | ||
| 31 | |||
| 32 | with | ||
| 33 | |||
| 34 | use CGI::Carp | ||
| 35 | |||
| 36 | And the standard warn(), die (), croak(), confess() and carp() calls | ||
| 37 | will automagically be replaced with functions that write out nicely | ||
| 38 | time-stamped messages to the HTTP server error log. | ||
| 39 | |||
| 40 | For example: | ||
| 41 | |||
| 42 | [Fri Nov 17 21:40:43 1995] test.pl: I'm confused at test.pl line 3. | ||
| 43 | [Fri Nov 17 21:40:43 1995] test.pl: Got an error message: Permission denied. | ||
| 44 | [Fri Nov 17 21:40:43 1995] test.pl: I'm dying. | ||
| 45 | |||
| 46 | =head1 REDIRECTING ERROR MESSAGES | ||
| 47 | |||
| 48 | By default, error messages are sent to STDERR. Most HTTPD servers | ||
| 49 | direct STDERR to the server's error log. Some applications may wish | ||
| 50 | to keep private error logs, distinct from the server's error log, or | ||
| 51 | they may wish to direct error messages to STDOUT so that the browser | ||
| 52 | will receive them. | ||
| 53 | |||
| 54 | The C<carpout()> function is provided for this purpose. Since | ||
| 55 | carpout() is not exported by default, you must import it explicitly by | ||
| 56 | saying | ||
| 57 | |||
| 58 | use CGI::Carp qw(carpout); | ||
| 59 | |||
| 60 |