⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handlers.pm

📁 source of perl for linux application,
💻 PM
字号:
package Log::Message::Handlers;use strict;=pod=head1 NAMELog::Message::Handlers - Message handlers for Log::Message=head1 SYNOPSIS    # Implicitly used by Log::Message to serve as handlers for    # Log::Message::Item objects    # Create your own file with a package called    # Log::Message::Handlers to add to the existing ones, or to even    # overwrite them    $item->carp;    $item->trace;=head1 DESCRIPTIONLog::Message::Handlers provides handlers for Log::Message::Item objects.The handler corresponding to the level (see Log::Message::Item manpagefor an explanation about levels) will be called automatically uponstoring the error.Handlers may also explicitly be called on an Log::Message::Item objectif one so desires (see the Log::Message manpage on how to retrieve theItem objects).=head1 Default Handlers=head2 logWill simply log the error on the stack, and do nothing special=cutsub log { 1 }=head2 carpWill carp (see the Carp manpage) with the error, and add the timestampof when it occurred.=cutsub carp {    my $self = shift;    warn join " ", $self->message, $self->shortmess, 'at', $self->when, "\n";}=head2 croakWill croak (see the Carp manpage) with the error, and add thetimestamp of when it occurred.=cutsub croak {    my $self = shift;    die join " ", $self->message, $self->shortmess, 'at', $self->when, "\n";}=head2 cluckWill cluck (see the Carp manpage) with the error, and add thetimestamp of when it occurred.=cutsub cluck {    my $self = shift;    warn join " ", $self->message, $self->longmess, 'at', $self->when, "\n";}=head2 confessWill confess (see the Carp manpage) with the error, and add thetimestamp of when it occurred=cutsub confess {    my $self = shift;    die join " ", $self->message, $self->longmess, 'at', $self->when, "\n";}=head2 dieWill simply die with the error message of the item=cutsub die  { die  shift->message; }=head2 warnWill simply warn with the error message of the item=cutsub warn { warn shift->message; }=head2 traceWill provide a traceback of this error item back to the first one thatoccurrent, clucking with every item as it comes across it.=cutsub trace {    my $self = shift;    for my $item( $self->parent->retrieve( chrono => 0 ) ) {        $item->cluck;    }}=head1 Custom HandlersIf you wish to provide your own handlers, you can simply do thefollowing:=over 4=item *Create a file that holds a package by the name ofC<Log::Message::Handlers>=item *Create subroutines with the same name as the levels you wish tohandle in the Log::Message module (see the Log::Message manpage forexplanation on levels)=item *Require that file in your program, or add it in your configuration(see the Log::Message::Config manpage for explanation on how to use aconfig file)=backAnd that is it, the handler will now be available to handle messagesfor you.The arguments a handler may receive are those specified by theC<extra> key, when storing the message.See the Log::Message manpage for details on the arguments.=head1 SEE ALSOL<Log::Message>, L<Log::Message::Item>, L<Log::Message::Config>=head1 AUTHORThis module byJos Boumans E<lt>kane@cpan.orgE<gt>.=head1 AcknowledgementsThanks to Ann Barcomb for her suggestions.=head1 COPYRIGHTThis module iscopyright (c) 2002 Jos Boumans E<lt>kane@cpan.orgE<gt>.All rights reserved.This library is free software;you may redistribute and/or modify it under the sameterms as Perl itself.=cut1;# Local variables:# c-indentation-style: bsd# c-basic-offset: 4# indent-tabs-mode: nil# End:# vim: expandtab shiftwidth=4:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -