\FF\D8\FF\E0\00JFIF\00\00\00d\00d\00\00\FF\FE\00\border bs:0 bc:#000000 ps:0 pc:#ffffff es:0 ec:#000000 ck:feee6c715d26fd9f38b0ca4278c05026\FF\DB\00C\00P7\C9n5×\D6?\BDê\9Ds\EBp\9F[`8m\B7)o\B5\E8\E6I\99\FE3]]A2\BA\8Cw\D6E\93\\DEv\C8\009\F2\F1NI?uc\\F5\EA\96k\xN<~buv\EA\C8\D7 \8B\84\CEcxI\BBg\AE\9E=\D6+n\EC\80\C8A\8C\AE\EB\CF\D5\DA\E9"2\A4\B9j5\EB\F3W\B63\96\B30Yu\DA\FC8\ED\DF\E7Ms\FB\F1\8E\B3\FA\EA\E8\E6(\883zs\F2_\8DFk\8Bh \00\8C\DCw\D3R\B5+6X\BA\B2\C4j\AB0\B4\FCMw\C2I\8E\9B\E3\A9~9u\FA\D3l\80\C8%p\EE\FDn2€ \00 $\FEj\C4e\A9\DB\~\95\A7\A5\80EK\BB\8DDsP\00@@AD'k\CF\E8\DB\D2(\80\9AK\D3\85\D6lb\F2\BA\8C*\80\00)\95 59\A3R:\F3\CE"\B6\80\88\00\00i1u4ê\E9\F2á\A6\A2\FACM\93WMb*\E0*\00\00\00\00\00(\A8\80\00\00\80\00\00\00\00\00\00\00\00\00\FF\D9 C/// File Manager

File Manager

Path: /usr/share/perl5/vendor_perl/Log/Message/

Viewing File: Handlers.pm

package Log::Message::Handlers;
use if $] > 5.017, 'deprecate';
use strict;
use vars qw[$VERSION];

$VERSION = '0.08';

=pod

=head1 NAME

Log::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 DESCRIPTION

Log::Message::Handlers provides handlers for Log::Message::Item objects.
The handler corresponding to the level (see Log::Message::Item manpage
for an explanation about levels) will be called automatically upon
storing the error.

Handlers may also explicitly be called on an Log::Message::Item object
if one so desires (see the Log::Message manpage on how to retrieve the
Item objects).

=head1 Default Handlers

=head2 log

Will simply log the error on the stack, and do nothing special

=cut

sub log { 1 }

=head2 carp

Will carp (see the Carp manpage) with the error, and add the timestamp
of when it occurred.

=cut

sub carp {
    my $self = shift;
    warn join " ", $self->message, $self->shortmess, 'at', $self->when, "\n";
}

=head2 croak

Will croak (see the Carp manpage) with the error, and add the
timestamp of when it occurred.

=cut

sub croak {
    my $self = shift;
    die join " ", $self->message, $self->shortmess, 'at', $self->when, "\n";
}

=head2 cluck

Will cluck (see the Carp manpage) with the error, and add the
timestamp of when it occurred.

=cut

sub cluck {
    my $self = shift;
    warn join " ", $self->message, $self->longmess, 'at', $self->when, "\n";
}

=head2 confess

Will confess (see the Carp manpage) with the error, and add the
timestamp of when it occurred

=cut

sub confess {
    my $self = shift;
    die join " ", $self->message, $self->longmess, 'at', $self->when, "\n";
}

=head2 die

Will simply die with the error message of the item

=cut

sub die  { die  shift->message; }


=head2 warn

Will simply warn with the error message of the item

=cut

sub warn { warn shift->message; }


=head2 trace

Will provide a traceback of this error item back to the first one that
occurred, clucking with every item as it comes across it.

=cut

sub trace {
    my $self = shift;

    for my $item( $self->parent->retrieve( chrono => 0 ) ) {
        $item->cluck;
    }
}

=head1 Custom Handlers

If you wish to provide your own handlers, you can simply do the
following:

=over 4

=item *

Create a file that holds a package by the name of
C<Log::Message::Handlers>

=item *

Create subroutines with the same name as the levels you wish to
handle in the Log::Message module (see the Log::Message manpage for
explanation 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 a
config file)

=back

And that is it, the handler will now be available to handle messages
for you.

The arguments a handler may receive are those specified by the
C<extra> key, when storing the message.
See the Log::Message manpage for details on the arguments.

=head1 SEE ALSO

L<Log::Message>, L<Log::Message::Item>, L<Log::Message::Config>

=head1 AUTHOR

This module by
Jos Boumans E<lt>kane@cpan.orgE<gt>.

=head1 Acknowledgements

Thanks to Ann Barcomb for her suggestions.

=head1 COPYRIGHT

This module is
copyright (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 same
terms as Perl itself.

=cut

1;

# Local variables:
# c-indentation-style: bsd
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
# vim: expandtab shiftwidth=4: