| TraceMessages(3pm) | User Contributed Perl Documentation | TraceMessages(3pm) |
Log::TraceMessages - Perl extension for trace messages used in debugging
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();
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.
"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.
Ed Avis, ed@membled.com
perl(1), Data::Dumper(3).
Hey! The above document had some coding errors, which are explained below:
| 2022-06-15 | perl v5.34.0 |