man Log::TraceMessages () - Perl extension for trace messages used in debugging

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 CWlocal-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 CW$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 CW$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 CW$CGI is true or CW$Logfile is set, each message will be printed to stderr with a newline appended.
trace(messages)
Synonym for CWt(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. CWd() 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 CWd(scalar).
check_argv()
Looks at the global CW@ARGV of command-line parameters to find one called '--trace'. If this is found, it will be removed from CW@ARGV and tracing will be turned on. Since tracing is off by default, calling CWcheck_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