Gestionnaire de fichiers - Editer - /usr/local/share/man/man3/CGI::Carp.3pm
Arrière
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "CGI::Carp 3" .TH CGI::Carp 3 "2020-02-03" "perl v5.16.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CGI::Carp \- CGI routines for writing to the HTTPD (or other) error log .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use CGI::Carp; \& \& croak "We\*(Aqre outta here!"; \& confess "It was my fault: $!"; \& carp "It was your fault!"; \& warn "I\*(Aqm confused"; \& die "I\*(Aqm dying.\en"; \& \& use CGI::Carp qw(cluck); \& cluck "I wouldn\*(Aqt do that if I were you"; \& \& use CGI::Carp qw(fatalsToBrowser); \& die "Fatal error messages are now sent to browser"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1CGI\s0 scripts have a nasty habit of leaving warning messages in the error logs that are neither time stamped nor fully identified. Tracking down the script that caused the error is a pain. This fixes that. Replace the usual .PP .Vb 1 \& use Carp; .Ve .PP with .PP .Vb 1 \& use CGI::Carp .Ve .PP The standard \fIwarn()\fR, die (), \fIcroak()\fR, \fIconfess()\fR and \fIcarp()\fR calls will be replaced with functions that write time-stamped messages to the \&\s-1HTTP\s0 server error log. .PP For example: .PP .Vb 3 \& [Fri Nov 17 21:40:43 1995] test.pl: I\*(Aqm confused at test.pl line 3. \& [Fri Nov 17 21:40:43 1995] test.pl: Got an error message: Permission denied. \& [Fri Nov 17 21:40:43 1995] test.pl: I\*(Aqm dying. .Ve .SH "REDIRECTING ERROR MESSAGES" .IX Header "REDIRECTING ERROR MESSAGES" By default, error messages are sent to \s-1STDERR. \s0 Most \s-1HTTPD\s0 servers direct \s-1STDERR\s0 to the server's error log. Some applications may wish to keep private error logs, distinct from the server's error log, or they may wish to direct error messages to \s-1STDOUT\s0 so that the browser will receive them. .PP The \f(CW\*(C`carpout()\*(C'\fR function is provided for this purpose. Since \&\fIcarpout()\fR is not exported by default, you must import it explicitly by saying .PP .Vb 1 \& use CGI::Carp qw(carpout); .Ve .PP The \fIcarpout()\fR function requires one argument, a reference to an open filehandle for writing errors. It should be called in a \f(CW\*(C`BEGIN\*(C'\fR block at the top of the \s-1CGI\s0 application so that compiler errors will be caught. Example: .PP .Vb 6 \& BEGIN { \& use CGI::Carp qw(carpout); \& open(LOG, ">>/usr/local/cgi\-logs/mycgi\-log") or \& die("Unable to open mycgi\-log: $!\en"); \& carpout(LOG); \& } .Ve .PP \&\fIcarpout()\fR does not handle file locking on the log for you at this point. Also, note that \fIcarpout()\fR does not work with in-memory file handles, although a patch would be welcome to address that. .PP The real \s-1STDERR\s0 is not closed \*(-- it is moved to CGI::Carp::SAVEERR. Some servers, when dealing with \s-1CGI\s0 scripts, close their connection to the browser when the script closes \s-1STDOUT\s0 and \s-1STDERR.\s0 CGI::Carp::SAVEERR is there to prevent this from happening prematurely. .PP You can pass filehandles to \fIcarpout()\fR in a variety of ways. The \*(L"correct\*(R" way according to Tom Christiansen is to pass a reference to a filehandle \&\s-1GLOB:\s0 .PP .Vb 1 \& carpout(\e*LOG); .Ve .PP This looks weird to mere mortals however, so the following syntaxes are accepted as well: .PP .Vb 5 \& carpout(LOG); \& carpout(main::LOG); \& carpout(main\*(AqLOG); \& carpout(\eLOG); \& carpout(\e\*(Aqmain::LOG\*(Aq); \& \& ... and so on .Ve .PP FileHandle and other objects work as well. .PP Use of \fIcarpout()\fR is not great for performance, so it is recommended for debugging purposes or for moderate-use applications. A future version of this module may delay redirecting \s-1STDERR\s0 until one of the CGI::Carp methods is called to prevent the performance hit. .SH "MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW" .IX Header "MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW" If you want to send fatal (die, confess) errors to the browser, import the special \*(L"fatalsToBrowser\*(R" subroutine: .PP .Vb 2 \& use CGI::Carp qw(fatalsToBrowser); \& die "Bad error here"; .Ve .PP Fatal errors will now be echoed to the browser as well as to the log. CGI::Carp arranges to send a minimal \s-1HTTP\s0 header to the browser so that even errors that occur in the early compile phase will be seen. Nonfatal errors will still be directed to the log file only (unless redirected with carpout). .PP Note that fatalsToBrowser may \fBnot\fR work well with mod_perl version 2.0 and higher. .SS "Changing the default message" .IX Subsection "Changing the default message" By default, the software error message is followed by a note to contact the Webmaster by e\-mail with the time and date of the error. If this message is not to your liking, you can change it using the \&\fIset_message()\fR routine. This is not imported by default; you should import it on the \fIuse()\fR line: .PP .Vb 2 \& use CGI::Carp qw(fatalsToBrowser set_message); \& set_message("It\*(Aqs not a bug, it\*(Aqs a feature!"); .Ve .PP You may also pass in a code reference in order to create a custom error message. At run time, your code will be called with the text of the error message that caused the script to die. Example: .PP .Vb 9 \& use CGI::Carp qw(fatalsToBrowser set_message); \& BEGIN { \& sub handle_errors { \& my $msg = shift; \& print "<h1>Oh gosh</h1>"; \& print "<p>Got an error: $msg</p>"; \& } \& set_message(\e&handle_errors); \& } .Ve .PP In order to correctly intercept compile-time errors, you should call \&\fIset_message()\fR from within a BEGIN{} block. .SH "DOING MORE THAN PRINTING A MESSAGE IN THE EVENT OF PERL ERRORS" .IX Header "DOING MORE THAN PRINTING A MESSAGE IN THE EVENT OF PERL ERRORS" If fatalsToBrowser in conjunction with set_message does not provide you with all of the functionality you need, you can go one step further by specifying a function to be executed any time a script calls \*(L"die\*(R", has a syntax error, or dies unexpectedly at runtime with a line like \*(L"undef\->\fIexplode()\fR;\*(R". .PP .Vb 7 \& use CGI::Carp qw(set_die_handler); \& BEGIN { \& sub handle_errors { \& my $msg = shift; \& print "content\-type: text/html\en\en"; \& print "<h1>Oh gosh</h1>"; \& print "<p>Got an error: $msg</p>"; \& \& #proceed to send an email to a system administrator, \& #write a detailed message to the browser and/or a log, \& #etc.... \& } \& set_die_handler(\e&handle_errors); \& } .Ve .PP Notice that if you use \fIset_die_handler()\fR, you must handle sending \&\s-1HTML\s0 headers to the browser yourself if you are printing a message. .PP If you use \fIset_die_handler()\fR, you will most likely interfere with the behavior of fatalsToBrowser, so you must use this or that, not both. .PP Using \fIset_die_handler()\fR sets SIG{_\|_DIE_\|_} (as does fatalsToBrowser), and there is only one SIG{_\|_DIE_\|_}. This means that if you are attempting to set SIG{_\|_DIE_\|_} yourself, you may interfere with this module's functionality, or this module may interfere with your module's functionality. .SH "SUPPRESSING PERL ERRORS APPEARING IN THE BROWSER WINDOW" .IX Header "SUPPRESSING PERL ERRORS APPEARING IN THE BROWSER WINDOW" A problem sometimes encountered when using fatalsToBrowser is when a \f(CW\*(C`die()\*(C'\fR is done inside an \f(CW\*(C`eval\*(C'\fR body or expression. Even though the fatalsToBrower support takes precautions to avoid this, you still may get the error message printed to \s-1STDOUT.\s0 This may have some undesirable effects when the purpose of doing the eval is to determine which of several algorithms is to be used. .PP By setting \f(CW$CGI::Carp::TO_BROWSER\fR to 0 you can suppress printing the \f(CW\*(C`die\*(C'\fR messages but without all of the complexity of using \&\f(CW\*(C`set_die_handler\*(C'\fR. You can localize this effect to inside \f(CW\*(C`eval\*(C'\fR bodies if this is desirable: For example: .PP .Vb 5 \& eval { \& local $CGI::Carp::TO_BROWSER = 0; \& die "Fatal error messages not sent browser" \& } \& # $@ will contain error message .Ve .SH "MAKING WARNINGS APPEAR AS HTML COMMENTS" .IX Header "MAKING WARNINGS APPEAR AS HTML COMMENTS" It is also possible to make non-fatal errors appear as \s-1HTML\s0 comments embedded in the output of your program. To enable this feature, export the new \*(L"warningsToBrowser\*(R" subroutine. Since sending warnings to the browser before the \s-1HTTP\s0 headers have been sent would cause an error, any warnings are stored in an internal buffer until you call the \fIwarningsToBrowser()\fR subroutine with a true argument: .PP .Vb 4 \& use CGI::Carp qw(fatalsToBrowser warningsToBrowser); \& use CGI qw(:standard); \& print header(); \& warningsToBrowser(1); .Ve .PP You may also give a false argument to \fIwarningsToBrowser()\fR to prevent warnings from being sent to the browser while you are printing some content where \s-1HTML\s0 comments are not allowed: .PP .Vb 5 \& warningsToBrowser(0); # disable warnings \& print "<script type=\e"text/javascript\e"><!\-\-\en"; \& print_some_javascript_code(); \& print "//\-\-></script>\en"; \& warningsToBrowser(1); # re\-enable warnings .Ve .PP Note: In this respect \fIwarningsToBrowser()\fR differs fundamentally from \&\fIfatalsToBrowser()\fR, which you should never call yourself! .SH "OVERRIDING THE NAME OF THE PROGRAM" .IX Header "OVERRIDING THE NAME OF THE PROGRAM" CGI::Carp includes the name of the program that generated the error or warning in the messages written to the log and the browser window. Sometimes, Perl can get confused about what the actual name of the executed program was. In these cases, you can override the program name that CGI::Carp will use for all messages. .PP The quick way to do that is to tell CGI::Carp the name of the program in its use statement. You can do that by adding \&\*(L"name=cgi_carp_log_name\*(R" to your \*(L"use\*(R" statement. For example: .PP .Vb 1 \& use CGI::Carp qw(name=cgi_carp_log_name); .Ve .PP \&. If you want to change the program name partway through the program, you can use the \f(CW\*(C`set_progname()\*(C'\fR function instead. It is not exported by default, you must import it explicitly by saying .PP .Vb 1 \& use CGI::Carp qw(set_progname); .Ve .PP Once you've done that, you can change the logged name of the program at any time by calling .PP .Vb 1 \& set_progname(new_program_name); .Ve .PP You can set the program back to the default by calling .PP .Vb 1 \& set_progname(undef); .Ve .PP Note that this override doesn't happen until after the program has compiled, so any compile-time errors will still show up with the non-overridden program name .SH "TURNING OFF TIMESTAMPS IN MESSAGES" .IX Header "TURNING OFF TIMESTAMPS IN MESSAGES" If your web server automatically adds a timestamp to each log line, you may not need CGI::Carp to add its own. You can disable timestamping by importing \*(L"noTimestamp\*(R": .PP .Vb 1 \& use CGI::Carp qw(noTimestamp); .Ve .PP Alternatively you can set \f(CW$CGI::Carp::NO_TIMESTAMP\fR to 1. .PP Note that the name of the program is still automatically included in the message. .SH "GETTING THE FULL PATH OF THE SCRIPT IN MESSAGES" .IX Header "GETTING THE FULL PATH OF THE SCRIPT IN MESSAGES" Set \f(CW$CGI::Carp::FULL_PATH\fR to 1. .SH "AUTHOR INFORMATION" .IX Header "AUTHOR INFORMATION" The \s-1CGI\s0.pm distribution is copyright 1995\-2007, Lincoln D. Stein. It is distributed under the Artistic License 2.0. It is currently maintained by Lee Johnson with help from many contributors. .PP Address bug reports and comments to: https://github.com/leejo/CGI.pm/issues .PP The original bug tracker can be found at: https://rt.cpan.org/Public/Dist/Display.html?Queue=CGI.pm .PP When sending bug reports, please provide the version of \s-1CGI\s0.pm, the version of Perl, the name and version of your Web server, and the name and version of the operating system you are using. If the problem is even remotely browser dependent, please provide information about the affected browsers as well. .SH "SEE ALSO" .IX Header "SEE ALSO" Carp, CGI::Base, CGI::BasePlus, CGI::Request, CGI::MiniSvr, CGI::Form, CGI::Response.
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0.02 |
proxy
|
phpinfo
|
Réglages