Log::Any is a Perl module that allows CPAN modules to safely and efficiently log messages, while letting the application choose (or decline to choose) a logging mechanism such as Log::Dispatch or Log::Log4perl.
Log::Any has a very tiny footprint and no dependencies beyond Perl 5.6, which makes it appropriate for even small CPAN modules to use. It defaults to 'null' logging activity, so a module can safely log without worrying about whether the application has chosen (or will ever choose) a logging mechanism.
The application, in turn, may choose one or more logging mechanisms via Log::Any::Adapter.
SYNOPSIS
In a CPAN or other module:
package Foo;
use Log::Any qw($log);
$log->error("an error occurred");
$log->debugf("arguments are: %s", \@_)
if $log->is_debug();
my $log2 = Log::Any->get_logger(category => 'My::Class');
In your application:
use Log::Any::Adapter;
# Send all logs to Log::Log4perl
Log::Any::Adapter->set('Log4perl');
# Send all logs to Log::Dispatch
my $log = Log::Dispatch->new(outputs => [[ ... ]]);
Log::Any::Adapter->set( 'Dispatch', dispatcher => $log );
# See Log::Any::Adapter documentation for more options
Product's homepage
Requirements:
· Perl