Log::Dispatch::WarnDie - Log standard Perl warnings and errors
use Log::Dispatch::WarnDie; # install to be used later my $dispatcher = Log::Dispatch->new; $dispatcher->add( Log::Dispatch::WarnDie->new( name => 'foo', min_level => 'info', ) ); use Log::Dispatch::WarnDie $dispatcher; # activate later Log::Dispatch::WarnDie->dispatcher( $dispatcher ); # same warn "This is a warning"; # now also dispatched die "Sorry it didn't work out"; # now also dispatched no Log::Dispatch::WarnDie; # deactivate later Log::Dispatch::WarnDie->dispatcher( undef ); # same warn "This is a warning"; # no longer dispatched die "Sorry it didn't work out"; # no longer dispatched
The "Log::Dispatch::WarnDie" module offers a logging alternative for standard Perl core functions. This allows you to use the features of Log::Dispatch without having to make extensive changes to your source code.
When loaded, it installs a __WARN__ and __DIE__ handler. It also takes over the messaging functions of Carp. Without being further activated, the standard Perl logging functions continue to be done.
Then, when necessary, you can activate actual logging through Log::Dispatch by installing a log dispatcher. From then on, any warn, die, carp, croak, cluck or confess will be logged using the Log::Dispatch logging dispatcher. Logging can be disabled and enabled at any time for critical sections of code.
(none)
The following caveats may apply to your situation.
Although Log::Dispatch is not listed as a prerequisite, the real use of this module only comes into view when that module is installed. Please note that for testing this module, you will need the Log::Dispatch::Buffer module to also be available.
In the current implementation of Perl, a __DIE__ handler is also called inside an eval. Whereas a normal die would just exit the eval, the __DIE__ handler _will_ get called inside the eval. Which may or may not be what you want. To prevent the __DIE__ handler to be called inside eval's, add the following line to the eval block or string being evaluated:
die
local $SIG{__DIE__} = undef;
This disables the __DIE__ handler within the evalled block or string, and will automatically enable it again upon exit of the evalled block or string. Unfortunately there is no automatic way to do that for you.
Elizabeth Mattijsen, <liz@dijkmat.nl>.
maintained by LNATION, <thisusedtobeanemail@gmail.com>
Please report bugs to <perlbugs@dijkmat.nl>.
Copyright (c) 2004 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Log::Dispatch::WarnDie, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Dispatch::WarnDie
CPAN shell
perl -MCPAN -e shell install Log::Dispatch::WarnDie
For more information on module installation, please visit the detailed CPAN module installation guide.