1TraceMessages(3)      User Contributed Perl Documentation     TraceMessages(3)
2
3
4

NAME

6       Log::TraceMessages - Perl extension for trace messages used in
7       debugging
8

SYNOPSIS

10         use Log::TraceMessages qw(t d);
11         $Log::TraceMessages::On = 1;
12         t 'got to here';
13         t 'value of $a is ' . d($a);
14         {
15             local $Log::TraceMessages::On = 0;
16             t 'this message will not be printed';
17         }
18
19         $Log::TraceMessages::Logfile = 'log.out';
20         t 'this message will go to the file log.out';
21         $Log::TraceMessages::Logfile = undef;
22         t 'and this message is on stderr as usual';
23
24         # For a CGI program producing HTML
25         $Log::TraceMessages::CGI = 1;
26
27         # Or to turn on trace if there's a command-line argument '--trace'
28         Log::TraceMessages::check_argv();
29

DESCRIPTION

31       This module is a slightly better way to put trace statements into your
32       code than just calling print().  It provides an easy way to turn trace
33       on and off for particular sections of code without having to comment
34       out bits of source.
35

USAGE

37       $Log::TraceMessages::On
38           Flag controlling whether tracing is on or off.  You can set it as
39           you wish, and of course it can be "local"-ized.  The default is
40           off.
41
42       $Log::TraceMessages::Logfile
43           The name of the file to which trace should be appended.  If this is
44           undefined (which is the default), then trace will be written to
45           stderr, or to stdout if $CGI is set.
46
47       $Log::TraceMessages::CGI
48           Flag controlling whether the program printing trace messages is a
49           CGI program (default is no).  This means that trace messages will
50           be printed as HTML.  Unless $Logfile is also set, messages will be
51           printed to stdout so they appear in the output page.
52
53       t(messages)
54           Print the given strings, if tracing is enabled.  Unless $CGI is
55           true or $Logfile is set, each message will be printed to stderr
56           with a newline appended.
57
58       trace(messages)
59           Synonym for "t(messages)".
60
61       d(scalar)
62           Return a string representation of a scalar's value suitable for use
63           in a trace statement.  This is just a wrapper for Data::Dumper.
64
65           "d()" will exit with '' if trace is not turned on.  This is to stop
66           your program being slowed down by generating lots of strings for
67           trace statements that are never printed.
68
69       dmp(scalar)
70           Synonym for "d(scalar)".
71
72       check_argv()
73           Looks at the global @ARGV of command-line parameters to find one
74           called '--trace'.  If this is found, it will be removed from @ARGV
75           and tracing will be turned on.  Since tracing is off by default,
76           calling "check_argv()" is a way to make your program print trace
77           only when you ask for it from the command line.
78

AUTHOR

80       Ed Avis, ed@membled.com
81

SEE ALSO

83       perl(1), Data::Dumper(3).
84

POD ERRORS

86       Hey! The above document had some coding errors, which are explained
87       below:
88
89       Around line 218:
90           You forgot a '=back' before '=head1'
91
92
93
94perl v5.36.0                      2022-07-22                  TraceMessages(3)
Impressum