.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Apache::TestTrace 3pm" .TH Apache::TestTrace 3pm 2024-01-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Apache::TestTrace \- Helper output generation functions .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& 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\en"; \& $_\->($_,[1..3],$_) for qw(emerg alert crit error \& warning notice info debug todo); \& print $Apache::TestTrace::LogFH "\en\en" \& }; \& \& # demo the trace subs using default setting \& test(); \& \& { \& # override the default trace level with \*(Aqcrit\*(Aq \& local $Apache::TestTrace::Level = \*(Aqcrit\*(Aq; \& # now only \*(Aqcrit\*(Aq and higher levels will do tracing lower level \& test(); \& } \& \& { \& # set the trace level to \*(Aqdebug\*(Aq \& local $Apache::TestTrace::Level = \*(Aqdebug\*(Aq; \& # now only \*(Aqdebug\*(Aq and higher levels will do tracing lower level \& test(); \& } \& \& { \& open OUT, ">/tmp/foo" or die $!; \& # override the default Log filehandle \& local $Apache::TestTrace::LogFH = \e*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 .Ve .SH DESCRIPTION .IX Header "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. .PP This module provides the same trace methods as \fBsyslog\fR\|(3)'s log levels. Listed from low level to high level: \fBemerg()\fR, \fBalert()\fR, \fBcrit()\fR, \&\fBerror()\fR, \fBwarning()\fR, \fBnotice()\fR, \fBinfo()\fR, \fBdebug()\fR. The only different function is \fBwarning()\fR, since warn is already taken by Perl. .PP The module provides another trace function called \fBtodo()\fR which is useful for todo items. It has the same level as \fIdebug\fR (the highest). .PP There are two more variants of each of these functions. If the \&\fI_mark\fR suffix is appended (e.g., \fIerror_mark\fR) the trace will start with the filename and the line number the function was called from. If the \fI_sub\fR suffix is appended (e.g., \fIerror_info\fR) the trace will start with the name of the subroutine the function was called from. .PP If you have \f(CW\*(C`Term::ANSIColor\*(C'\fR installed the diagnostic messages will be colorized, otherwise a special for each function prefix will be used. .PP If \f(CW\*(C`Data::Dumper\*(C'\fR is installed and you pass a reference to a variable to any of these functions, the variable will be dumped with \&\f(CWData::Dumper::Dumper()\fR. .PP Functions whose level is above the level set in \&\f(CW$Apache::TestTrace::Level\fR become NOPs. For example if the level is set to \fIalert\fR, only \fBalert()\fR and \fBemerg()\fR functions will generate the output. The default setting of this variable is \fIwarning\fR. Other valid values are: \fIemerg\fR, \fIalert\fR, \fIcrit\fR, \fIerror\fR, \fIwarning\fR, \&\fInotice\fR, \fIinfo\fR, \fIdebug\fR. .PP Another way to affect the trace level is to set \&\f(CW$ENV{APACHE_TEST_TRACE_LEVEL}\fR, which takes effect if \&\f(CW$Apache::TestTrace::Level\fR is not set. So an explicit setting of \&\f(CW$Apache::TestTrace::Level\fR always takes precedence. .PP By default all the output generated by these functions goes to STDERR. You can override the default filehandler by overriding \&\f(CW$Apache::TestTrace::LogFH\fR with a new filehandler. .PP 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. .SH TODO .IX Header "TODO" .Vb 2 \& o provide an option to disable the coloring altogether via some flag \& or import() .Ve .SH AUTHOR .IX Header "AUTHOR" Stas Bekman with contributions from Doug MacEachern