1 package Log::Message::Handlers;
8 Log::Message::Handlers - Message handlers for Log::Message
12 # Implicitly used by Log::Message to serve as handlers for
13 # Log::Message::Item objects
15 # Create your own file with a package called
16 # Log::Message::Handlers to add to the existing ones, or to even
26 Log::Message::Handlers provides handlers for Log::Message::Item objects.
27 The handler corresponding to the level (see Log::Message::Item manpage
28 for an explanation about levels) will be called automatically upon
31 Handlers may also explicitly be called on an Log::Message::Item object
32 if one so desires (see the Log::Message manpage on how to retrieve the
35 =head1 Default Handlers
39 Will simply log the error on the stack, and do nothing special
47 Will carp (see the Carp manpage) with the error, and add the timestamp
54 warn join " ", $self->message, $self->shortmess, 'at', $self->when, "\n";
59 Will croak (see the Carp manpage) with the error, and add the
60 timestamp of when it occurred.
66 die join " ", $self->message, $self->shortmess, 'at', $self->when, "\n";
71 Will cluck (see the Carp manpage) with the error, and add the
72 timestamp of when it occurred.
78 warn join " ", $self->message, $self->longmess, 'at', $self->when, "\n";
83 Will confess (see the Carp manpage) with the error, and add the
84 timestamp of when it occurred
90 die join " ", $self->message, $self->longmess, 'at', $self->when, "\n";
95 Will simply die with the error message of the item
99 sub die { die shift->message; }
104 Will simply warn with the error message of the item
108 sub warn { warn shift->message; }
113 Will provide a traceback of this error item back to the first one that
114 occurrent, clucking with every item as it comes across it.
121 for my $item( $self->parent->retrieve( chrono => 0 ) ) {
126 =head1 Custom Handlers
128 If you wish to provide your own handlers, you can simply do the
135 Create a file that holds a package by the name of
136 C<Log::Message::Handlers>
140 Create subroutines with the same name as the levels you wish to
141 handle in the Log::Message module (see the Log::Message manpage for
142 explanation on levels)
146 Require that file in your program, or add it in your configuration
147 (see the Log::Message::Config manpage for explanation on how to use a
152 And that is it, the handler will now be available to handle messages
155 The arguments a handler may receive are those specified by the
156 C<extra> key, when storing the message.
157 See the Log::Message manpage for details on the arguments.
161 L<Log::Message>, L<Log::Message::Item>, L<Log::Message::Config>
166 Jos Boumans E<lt>kane@cpan.orgE<gt>.
168 =head1 Acknowledgements
170 Thanks to Ann Barcomb for her suggestions.
175 copyright (c) 2002 Jos Boumans E<lt>kane@cpan.orgE<gt>.
178 This library is free software;
179 you may redistribute and/or modify it under the same
180 terms as Perl itself.
187 # c-indentation-style: bsd
189 # indent-tabs-mode: nil
191 # vim: expandtab shiftwidth=4: