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

Apache::TestTrace(3pm)					User Contributed Perl Documentation				    Apache::TestTrace(3pm)

NAME
Apache::TestTrace - Helper output generation functions SYNOPSIS
use Apache::TestTrace; debug "foo bar"; info_sub "missed it"; error_mark "something is wrong"; # test sub that exercises all the tracing functions sub test { print $Apache::TestTrace::LogFH "TraceLevel: $Apache::TestTrace::Level "; $_->($_,[1..3],$_) for qw(emerg alert crit error warning notice info debug todo); print $Apache::TestTrace::LogFH " " }; # demo the trace subs using default setting test(); { # override the default trace level with 'crit' local $Apache::TestTrace::Level = 'crit'; # now only 'crit' and higher levels will do tracing lower level test(); } { # set the trace level to 'debug' local $Apache::TestTrace::Level = 'debug'; # now only 'debug' and higher levels will do tracing lower level test(); } { open OUT, ">/tmp/foo" or die $!; # override the default Log filehandle local $Apache::TestTrace::LogFH = *OUT; # now the traces will go into a new filehandle test(); close OUT; } # override tracing level via -trace opt % t/TEST -trace=debug # override tracing level via env var % env APACHE_TEST_TRACE_LEVEL=debug t/TEST DESCRIPTION
This module exports a number of functions that make it easier generating various diagnostics messages in your programs in a consistent way and saves some keystrokes as it handles the new lines and sends the messages to STDERR for you. This module provides the same trace methods as syslog(3)'s log levels. Listed from low level to high level: emerg(), alert(), crit(), error(), warning(), notice(), info(), debug(). The only different function is warning(), since warn is already taken by Perl. The module provides another trace function called todo() which is useful for todo items. It has the same level as debug (the highest). There are two more variants of each of these functions. If the _mark suffix is appended (e.g., error_mark) the trace will start with the filename and the line number the function was called from. If the _sub suffix is appended (e.g., error_info) the trace will start with the name of the subroutine the function was called from. If you have "Term::ANSIColor" installed the diagnostic messages will be colorized, otherwise a special for each function prefix will be used. If "Data::Dumper" is installed and you pass a reference to a variable to any of these functions, the variable will be dumped with "Data::Dumper::Dumper()". Functions whose level is above the level set in $Apache::TestTrace::Level become NOPs. For example if the level is set to alert, only alert() and emerg() functions will generate the output. The default setting of this variable is warning. Other valid values are: emerg, alert, crit, error, warning, notice, info, debug. Another way to affect the trace level is to set $ENV{APACHE_TEST_TRACE_LEVEL}, which takes effect if $Apache::TestTrace::Level is not set. So an explicit setting of $Apache::TestTrace::Level always takes precedence. By default all the output generated by these functions goes to STDERR. You can override the default filehandler by overriding $Apache::TestTrace::LogFH with a new filehandler. When you override this package's global variables, think about localizing your local settings, so it won't affect other modules using this module in the same run. TODO
o provide an option to disable the coloring altogether via some flag or import() AUTHOR
Stas Bekman with contributions from Doug MacEachern perl v5.14.2 2013-03-12 Apache::TestTrace(3pm)
Man Page