Siffra::Logger - Siffra config for Log::Any
Log::Any
In a CPAN or other module:
package Foo; use Log::Any qw($log); use Siffra::Logger; # log a string $log->error("an error occurred"); # log a string and some data $log->info("program started", {progname => $0, pid => $$, perl_version => $]}); # log a string and data using a format string $log->debugf("arguments are: %s", \@_); # log an error and throw an exception die $log->fatal("a fatal error occurred");
In your application:
use Foo; use Log::Any qw($log); use Siffra::Logger; # log a string $log->error("an error occurred"); # log a string and some data $log->info("program started", {progname => $0, pid => $$, perl_version => $]}); # log a string and data using a format string $log->debugf("arguments are: %s", \@_); # log an error and throw an exception die $log->fatal("a fatal error occurred");
Directory Creation
my ( $filename, $baseDirectory, $suffix ) = fileparse( $0, qr/\.[^.]*/ ); my $logDirectory = $baseDirectory . 'logs/'; my $logFilename = $filename . '.log'; croak( "Unable to create $logDirectory" ) unless ( -e $logDirectory or mkdir $logDirectory );
Outputs
[ 'Screen', name => 'screen', min_level => 'debug', max_level => 'warning', newline => 1, utf8 => 0, stderr => 0, use_color => 1, ], [ 'Screen', name => 'screen-error', min_level => 'error', newline => 1, utf8 => 0, stderr => 1, use_color => 1, ], [ 'File', name => 'file-01', filename => $logDirectory . $logFilename, min_level => 'debug', newline => 1, mode => 'write', binmode => ':encoding(UTF-8)', ]
Siffra::logger provides a standart outputs to Log::Any
Siffra::logger
Luiz Benevenuto CPAN ID: LUIZBENE Siffra TI luiz@siffra.com.br https://siffra.com.br
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl(1).
To install Siffra::Logger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Siffra::Logger
CPAN shell
perl -MCPAN -e shell install Siffra::Logger
For more information on module installation, please visit the detailed CPAN module installation guide.