<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Python, Java, Life, etc

    A blog of technology and life.

    BlogJava 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
      30 Posts :: 0 Stories :: 9 Comments :: 0 Trackbacks

    NAME

    CGI::Carp - CGI routines for writing to the HTTPD (or other) error log


    SYNOPSIS

        use CGI::Carp;

        croak "We're outta here!";
    confess "It was my fault: $!";
    carp "It was your fault!";
    warn "I'm confused";
    die "I'm dying.\n";


    DESCRIPTION

    CGI 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

        use Carp;

    with

        use CGI::Carp

    And the standard warn(), die (), croak(), confess() and carp() calls will automagically be replaced with functions that write out nicely time-stamped messages to the HTTP server error log.

    For example:

       [Fri Nov 17 21:40:43 1995] test.pl: I'm 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'm dying.


    REDIRECTING ERROR MESSAGES

    By default, error messages are sent to STDERR. Most HTTPD servers direct STDERR 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 STDOUT so that the browser will receive them.

    The carpout() function is provided for this purpose. Since carpout() is not exported by default, you must import it explicitly by saying

       use CGI::Carp qw(carpout);

    The carpout() function requires one argument, which should be a reference to an open filehandle for writing errors. It should be called in a BEGIN block at the top of the CGI application so that compiler errors will be caught. Example:

       BEGIN {
    use CGI::Carp qw(carpout);
    open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or
    die("Unable to open mycgi-log: $!\n");
    carpout(LOG);
    }

    carpout() does not handle file locking on the log for you at this point.

    The real STDERR is not closed -- it is moved to SAVEERR. Some servers, when dealing with CGI scripts, close their connection to the browser when the script closes STDOUT and STDERR. SAVEERR is used to prevent this from happening prematurely.

    You can pass filehandles to carpout() in a variety of ways. The ``correct'' way according to Tom Christiansen is to pass a reference to a filehandle GLOB:

        carpout(\*LOG);

    This looks weird to mere mortals however, so the following syntaxes are accepted as well:

        carpout(LOG);
    carpout(main::LOG);
    carpout(main'LOG);
    carpout(\LOG);
    carpout(\'main::LOG');

        ... and so on

    FileHandle and other objects work as well.

    Use of carpout() 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 STDERR until one of the CGI::Carp methods is called to prevent the performance hit.


    MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW

    If you want to send fatal (die, confess) errors to the browser, ask to import the special ``fatalsToBrowser'' subroutine:

        use CGI::Carp qw(fatalsToBrowser);
    die "Bad error here";

    Fatal errors will now be echoed to the browser as well as to the log. CGI::Carp arranges to send a minimal HTTP 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).


    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 set_message() routine. This is not imported by default; you should import it on the use() line:

        use CGI::Carp qw(fatalsToBrowser set_message);
    set_message("It's not a bug, it's a feature!");

    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:

        use CGI::Carp qw(fatalsToBrowser set_message);
    BEGIN {
    sub handle_errors {
    my $msg = shift;
    print "<h1>Oh gosh</h1>";
    print "Got an error: $msg";
    }
    set_message(\&handle_errors);
    }

    In order to correctly intercept compile-time errors, you should call set_message() from within a BEGIN{} block.


    CHANGE LOG

    1.05 carpout() added and minor corrections by Marc Hedlund <hedlund@best.com> on 11/26/95.

    1.06 fatalsToBrowser() no longer aborts for fatal errors within eval() statements.

    1.08 set_message() added and carpout() expanded to allow for FileHandle objects.

    1.09 set_message() now allows users to pass a code REFERENCE for really custom error messages. croak and carp are now exported by default. Thanks to Gunther Birznieks for the patches.

    1.10 Patch from Chris Dean (ctdean@cogit.com) to allow module to run correctly under mod_perl.


    AUTHORS

    Lincoln D. Stein <lstein@genome.wi.mit.edu> Feel free to redistribute this under the Perl Artistic License.


    SEE ALSO

    Carp, CGI::Base, CGI::BasePlus, CGI::Request, CGI::MiniSvr, CGI::Form, CGI::Response


    DISCLAIMER

    We are painfully aware that these documents may contain incorrect links and misformatted HTML. Such bugs lie in the automatic translation process that automatically created the hundreds and hundreds of separate documents that you find here. Please do not report link or formatting bugs, because we cannot fix per-document problems. The only bug reports that will help us are those that supply working patches to the installhtml or pod2html programs, or to the Pod::HTML module itself, for which I and the entire Perl community will shower you with thanks and praises.

    If rather than formatting bugs, you encounter substantive content errors in these documents, such as mistakes in the explanations or code, please use the perlbug utility included with the Perl distribution.

    --Tom Christiansen, Perl Documentation Compiler and Editor


    Return to the Perl Documentation Index.
    Return to the Perl Home Page.
    posted on 2005-02-18 05:27 pyguru 閱讀(653) 評(píng)論(0)  編輯  收藏 所屬分類: Perl

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 四虎亚洲国产成人久久精品| 国产精品成人观看视频免费 | 国产精品亚洲不卡一区二区三区| 亚洲一卡2卡4卡5卡6卡残暴在线| 蜜桃AV无码免费看永久| 久久精品国产亚洲AV麻豆不卡| 免费91最新地址永久入口| 亚洲人成精品久久久久| 国产精品偷伦视频观看免费| 久热综合在线亚洲精品| 一级做a爰全过程免费视频| 亚洲国产精品自在在线观看| 一级毛片免费观看不卡的| 亚洲伊人久久大香线蕉苏妲己| 人妻无码久久一区二区三区免费 | 亚洲成人免费网址| 亚洲一区二区三区在线观看蜜桃 | 亚洲AV综合永久无码精品天堂| 国产jizzjizz视频全部免费| 美女黄频视频大全免费的| 亚洲片国产一区一级在线观看| 黄色网页在线免费观看| 久久亚洲国产伦理| av免费不卡国产观看| 亚洲JLZZJLZZ少妇| 亚洲中文无韩国r级电影 | 国产无遮挡又黄又爽免费网站| 亚洲av无码一区二区三区不卡| 国产精品成人免费福利| 亚洲一区AV无码少妇电影| 亚洲精品NV久久久久久久久久| 成人精品一区二区三区不卡免费看| 91精品国产亚洲爽啪在线影院| 中文字幕影片免费在线观看| 特级毛片A级毛片免费播放| 五月天网站亚洲小说| 成人爽A毛片免费看| 最近免费中文字幕中文高清| 亚洲欧洲日产v特级毛片| 免费观看国产小粉嫩喷水| 一区二区三区观看免费中文视频在线播放|