Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

log::contextual::simplelogger(3pm) [debian man page]

Log::Contextual::SimpleLogger(3pm)			User Contributed Perl Documentation			Log::Contextual::SimpleLogger(3pm)

NAME
Log::Contextual::SimpleLogger - Super simple logger made for playing with Log::Contextual SYNOPSIS
use Log::Contextual::SimpleLogger; 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' }; ... } DESCRIPTION
This module is a simple logger made mostly for demonstration and initial experimentation with Log::Contextual. We recommend you use a real logger instead. For something more serious but not overly complicated, take a look at Log::Dispatchouli. METHODS
new Arguments: "Dict[ levels => Optional[ArrayRef[Str]], levels_upto => Level, coderef => Optional[CodeRef], ] $conf" my $l = Log::Contextual::SimpleLogger->new({ levels => [qw( info warn )], coderef => sub { print @_ }, # the default prints to STDERR }); or my $l = Log::Contextual::SimpleLogger->new({ levels_upto => 'debug', coderef => sub { print @_ }, # the default prints to STDERR }); Creates a new SimpleLogger object with the passed levels enabled and optionally a "CodeRef" may be passed to modify how the logs are output/stored. "levels_upto" enables all the levels upto and including the level passed. Levels may contain: trace debug info warn error fatal $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{ }, @_; if $self->is_$level; } trace $l->trace( 'entered method foo with args ' join q{,}, @args ); debug $l->debug( 'entered method foo' ); info $l->info( 'started process foo' ); warn $l->warn( 'possible misconfiguration at line 10' ); error $l->error( 'non-numeric user input!' ); fatal $l->fatal( '1 is never equal to 0!' ); is_$level All of the following six functions just return true if their respective level is enabled. is_trace say 'tracing' if $l->is_trace; is_debug say 'debuging' if $l->is_debug; is_info say q{info'ing} if $l->is_info; is_warn say 'warning' if $l->is_warn; is_error say 'erroring' if $l->is_error; is_fatal say q{fatal'ing} if $l->is_fatal; AUTHOR
See "AUTHOR" in Log::Contextual COPYRIGHT
See "COPYRIGHT" in Log::Contextual LICENSE
See "LICENSE" in Log::Contextual perl v5.10.1 2010-07-31 Log::Contextual::SimpleLogger(3pm)

Check Out this Related Man Page

Log::Contextual::WarnLogger(3pm)			User Contributed Perl Documentation			  Log::Contextual::WarnLogger(3pm)

NAME
Log::Contextual::WarnLogger - Simple logger for libraries using Log::Contextual SYNOPSIS
package My::Package; use Log::Contextual::WarnLogger; use Log::Contextual qw( :log ), -default_logger => Log::Contextual::WarnLogger->new({ env_prefix => 'MY_PACKAGE' }); # warns '[info] program started' if $ENV{MY_PACKAGE_TRACE} is set log_info { 'program started' }; # no-op because info is not in levels sub foo { # warns '[debug] entered foo' if $ENV{MY_PACKAGE_DEBUG} is set log_debug { 'entered foo' }; ... } DESCRIPTION
This module is a simple logger made for libraries using Log::Contextual. We recommend the use of this logger as your default logger as it is simple and useful for most users, yet users can use "set_logger" in Log::Contextual to override your choice of logger in their own code thanks to the way Log::Contextual works. METHODS
new Arguments: "Dict[ env_prefix => Str ] $conf" my $l = Log::Contextual::WarnLogger->new({ env_prefix }); Creates a new logger object where "env_prefix" defines what the prefix is for the environment variables that will be checked for the six log levels. For example, if "env_prefix" is set to "FREWS_PACKAGE" the following environment variables will be used: FREWS_PACKAGE_UPTO FREWS_PACKAGE_TRACE FREWS_PACKAGE_DEBUG FREWS_PACKAGE_INFO FREWS_PACKAGE_WARN FREWS_PACKAGE_ERROR FREWS_PACKAGE_FATAL Note that "UPTO" is a convenience variable. If you set "FOO_UPTO=TRACE" it will enable all log levels. Similarly, if you set it to "FATAL" only fatal will be enabled. $level Arguments: @anything All of the following six methods work the same. The basic pattern is: sub $level { my $self = shift; warn "[$level] " . join qq{ }, @_; if $self->is_$level; } trace $l->trace( 'entered method foo with args ' join q{,}, @args ); debug $l->debug( 'entered method foo' ); info $l->info( 'started process foo' ); warn $l->warn( 'possible misconfiguration at line 10' ); error $l->error( 'non-numeric user input!' ); fatal $l->fatal( '1 is never equal to 0!' ); is_$level All of the following six functions just return true if their respective environment variable is enabled. is_trace say 'tracing' if $l->is_trace; is_debug say 'debuging' if $l->is_debug; is_info say q{info'ing} if $l->is_info; is_warn say 'warning' if $l->is_warn; is_error say 'erroring' if $l->is_error; is_fatal say q{fatal'ing} if $l->is_fatal; AUTHOR
See "AUTHOR" in Log::Contextual COPYRIGHT
See "COPYRIGHT" in Log::Contextual LICENSE
See "LICENSE" in Log::Contextual perl v5.10.1 2010-07-31 Log::Contextual::WarnLogger(3pm)
Man Page