Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

log::tracemessages(3pm) [debian man page]

TraceMessages(3pm)					User Contributed Perl Documentation					TraceMessages(3pm)

NAME
Log::TraceMessages - Perl extension for trace messages used in debugging SYNOPSIS
use Log::TraceMessages qw(t d); $Log::TraceMessages::On = 1; t 'got to here'; t 'value of $a is ' . d($a); { local $Log::TraceMessages::On = 0; t 'this message will not be printed'; } $Log::TraceMessages::Logfile = 'log.out'; t 'this message will go to the file log.out'; $Log::TraceMessages::Logfile = undef; t 'and this message is on stderr as usual'; # For a CGI program producing HTML $Log::TraceMessages::CGI = 1; # Or to turn on trace if there's a command-line argument '--trace' Log::TraceMessages::check_argv(); DESCRIPTION
This module is a slightly better way to put trace statements into your code than just calling print(). It provides an easy way to turn trace on and off for particular sections of code without having to comment out bits of source. USAGE
$Log::TraceMessages::On Flag controlling whether tracing is on or off. You can set it as you wish, and of course it can be "local"-ized. The default is off. $Log::TraceMessages::Logfile The name of the file to which trace should be appended. If this is undefined (which is the default), then trace will be written to stderr, or to stdout if $CGI is set. $Log::TraceMessages::CGI Flag controlling whether the program printing trace messages is a CGI program (default is no). This means that trace messages will be printed as HTML. Unless $Logfile is also set, messages will be printed to stdout so they appear in the output page. t(messages) Print the given strings, if tracing is enabled. Unless $CGI is true or $Logfile is set, each message will be printed to stderr with a newline appended. trace(messages) Synonym for "t(messages)". d(scalar) Return a string representation of a scalar's value suitable for use in a trace statement. This is just a wrapper for Data::Dumper. "d()" will exit with '' if trace is not turned on. This is to stop your program being slowed down by generating lots of strings for trace statements that are never printed. dmp(scalar) Synonym for "d(scalar)". check_argv() Looks at the global @ARGV of command-line parameters to find one called '--trace'. If this is found, it will be removed from @ARGV and tracing will be turned on. Since tracing is off by default, calling "check_argv()" is a way to make your program print trace only when you ask for it from the command line. AUTHOR
Ed Avis, ed@membled.com SEE ALSO
perl(1), Data::Dumper(3). perl v5.8.8 2006-05-27 TraceMessages(3pm)

Check Out this Related 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)
Man Page