From: Arthur Axel 'fREW' Schmidt Date: Sat, 20 Feb 2010 11:36:37 +0000 (-0600) Subject: done with pod unless mst complains X-Git-Tag: v0.00100~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8bc568d27358ab60b9df8b10cc81d71f696760ef;p=p5sagit%2FLog-Contextual.git done with pod unless mst complains --- diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index d3be981..17681dc 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -223,7 +223,7 @@ __END__ =head1 NAME -Log::Contextual - Super simple logging interface +Log::Contextual - Simple logging interface with a contextual log =head1 SYNOPSIS diff --git a/lib/Log/Contextual/SimpleLogger.pm b/lib/Log/Contextual/SimpleLogger.pm index 55d11f1..8e810cc 100644 --- a/lib/Log/Contextual/SimpleLogger.pm +++ b/lib/Log/Contextual/SimpleLogger.pm @@ -41,3 +41,130 @@ sub _log { 1; +__END__ + +=head1 NAME + +Log::Contextual::SimpleLogger - Super simple logger made for playing with Log::Contextual + +=head1 SYNOPSIS + + use Log::Contextual qw{:log}, + -logger => Log::Contextual::SimpleLogger->new({ levels => [qw{debug}]}); + + log_info { 'program started' }; # no-op because info is not in levels + sub foo { + log_debug { 'entered foo' }; + ... + } + +=head1 DESCRIPTION + +This module is a simple logger made mostly for demonstration and initial +experimentation with L. We recommend you use a real logger +instead. For something more serious but not overly complicated, take a look at +L. + +=head1 METHODS + +=head2 new + +Arguments: Dict[ levels => ArrayRef[Str], coderef => Optional[CodeRef] ] $conf + + my $l = Log::Contextual::SimpleLogger->new({ + levels => [qw{ info warn }], + coderef => sub { print @_ }, # the default prints to STDERR + }); + +Creates a new SimpleLogger object with the passed levels enabled and optionally +a C may be passed to modify how the logs are output/stored. + +Levels may contain: + + trace + debug + info + warn + error + fatal + +=head2 $level + +Arguments: @anything + +All of the following six methods work the same. The basic pattern is: + + sub $level { + my $self = shift; + + print STDERR "[$level] " . join qq{\n}, @_; + if $self->is_$level; + } + +=head3 trace + + $l->trace( 'entered method foo with args ' join q{,}, @args ); + +=head3 debug + + $l->debug( 'entered method foo' ); + +=head3 info + + $l->info( 'started process foo' ); + +=head3 warn + + $l->warn( 'possible misconfiguration at line 10' ); + +=head3 error + + $l->error( 'non-numeric user input!' ); + +=head3 fatal + + $l->fatal( '1 is never equal to 0!' ); + +=head2 is_$level + +All of the following six functions just return true if their respective +level is enabled. + +=head3 is_trace + + say 'tracing' if $l->is_trace; + +=head3 is_debug + + say 'debuging' if $l->is_debug; + +=head3 is_info + + say q{info'ing} if $l->is_info; + +=head3 is_warn + + say 'warning' if $l->is_warn; + +=head3 is_error + + say 'erroring' if $l->is_error; + +=head3 is_fatal + + say q{fatal'ing} if $l->is_fatal; + +=head1 AUTHOR + +See L + +=head1 COPYRIGHT + +See L + +=head1 LICENSE + +See L + +=cut +