NAME

Tools::Log::Handlers

SYNOPSIS

# Implicitly used by Tools::Log to serve as handlers for
# Tools::Log::Item objects

# Create your own file with a package called
# Tools::Log::Handlers to add to the existing ones, or to even
# overwrite them

$item->carp;

$item->trace;

DESCRIPTION

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

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

Default Handlers

log

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

carp

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

croak

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

cluck

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

confess

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

die

Will simply die with the error message of the item

warn

Will simply warn with the error message of the item

trace

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

Custom Handlers

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

  • Create a file that holds a package by the name of Tools::Log::Handlers

  • Create subroutines with the same name as the levels you wish to handle in the Tools::Log module (see the Tools::Log manpage for explenation on levels)

  • Require that file in your program, or add it in your configuration (see the Tools::Log::Config manpage for explenation on how to use a config file)

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 extra key, when storing the message. See the Tools::Log manpage for details on the arguments.

SEE ALSO

Tools::Log, Tools::Log::Item, Tools::Log::Config

AUTHOR

This module by Jos Boumans <kane@cpan.org>.

Acknowledgements

Thanks to Ann Barcomb for her suggestions.

COPYRIGHT

This module is copyright (c) 2002 Jos Boumans <kane@cpan.org>. All rights reserved.

This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.