Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

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

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

NAME
Log::Contextual::TeeLogger - Output to more than one logger SYNOPSIS
use Log::Contextual::SimpleLogger; use Log::Contextual::TeeLogger; use Log::Contextual qw( :log ), -logger => Log::Contextual::TeeLogger->new({ loggers => [ Log::Contextual::SimpleLogger->new({ levels => [ 'debug' ] }), Log::Contextual::SimpleLogger->new({ levels => [ 'info' ], coderef => sub { print @_ }, }), ]}); ## docs below here not yet edited 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 => 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 "CodeRef" may be passed to modify how the logs are output/stored. 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-09 Log::Contextual::TeeLogger(3pm)

Check Out this Related Man Page

Mojo::Log(3pm)						User Contributed Perl Documentation					    Mojo::Log(3pm)

NAME
Mojo::Log - Simple logger SYNOPSIS
use Mojo::Log; # Log to STDERR my $log = Mojo::Log->new; # Customize log file location and minimum log level my $log = Mojo::Log->new(path => '/var/log/mojo.log', level => 'warn'); # Log messages $log->debug("Why isn't this working?"); $log->info("FYI: it happened again"); $log->warn("This might be a problem"); $log->error("Garden variety error"); $log->fatal("Boom!"); DESCRIPTION
Mojo::Log is a simple logger for Mojo projects. EVENTS
Mojo::Log can emit the following events. "message" $log->on(message => sub { my ($log, $level, @messages) = @_; ... }); Emitted when a new message gets logged. $log->unsubscribe('message'); $log->on(message => sub { my ($log, $level, @messages) = @_; say "$level: ", @messages; }); ATTRIBUTES
Mojo::Log implements the following attributes. "handle" my $handle = $log->handle; $log = $log->handle(IO::Handle->new); Log file handle used by default "message" event, defaults to opening "path" or "STDERR". "level" my $level = $log->level; $log = $log->level('debug'); Active log level, defaults to the value of the "MOJO_LOG_LEVEL" environment variable or "debug". These levels are currently available: "debug" "info" "warn" "error" "fatal" "path" my $path = $log->path $log = $log->path('/var/log/mojo.log'); Log file path used by "handle". METHODS
Mojo::Log inherits all methods from Mojo::EventEmitter and implements the following new ones. "new" my $log = Mojo::Log->new; Construct a new Mojo::Log object and subscribe to "message" event with default logger. "debug" $log = $log->debug('You screwed up, but that is ok'); Log debug message. "error" $log = $log->error('You really screwed up this time'); Log error message. "fatal" $log = $log->fatal('Its over...'); Log fatal message. "format" my $message = $log->format('debug', 'Hi there!'); my $message = $log->format('debug', 'Hi', 'there!'); Format log message. "info" $log = $log->info('You are bad, but you prolly know already'); Log info message. "is_level" my $success = $log->is_level('debug'); Check log level. "is_debug" my $success = $log->is_debug; Check for debug log level. "is_error" my $success = $log->is_error; Check for error log level. "is_fatal" my $success = $log->is_fatal; Check for fatal log level. "is_info" my $success = $log->is_info; Check for info log level. "is_warn" my $success = $log->is_warn; Check for warn log level. "log" $log = $log->log(debug => 'This should work'); Emit "message" event. "warn" $log = $log->warn('Dont do that Dave...'); Log warn message. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Log(3pm)
Man Page