.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 "Paranoid::Debug 3pm" .TH Paranoid::Debug 3pm "2018-11-09" "perl v5.28.0" "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" Paranoid::Debug \- Trace message support for paranoid programs .SH "VERSION" .IX Header "VERSION" \&\f(CW$Id:\fR lib/Paranoid/Debug.pm, 2.06 2018/08/05 01:21:48 acorliss Exp $ .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Paranoid::Debug; \& \& PDEBUG = 1; \& PDMAXINDENT = 40; \& PDPREFIX = sub { scalar localtime }; \& pdebug("starting program", 1); \& foo(); \& \& sub foo { \& pdebug("entering foo()", 2); \& pIn(); \& \& pdebug("someting happened!", 2); \& \& pOut(); \& pdebug("leaving w/rv: $rv", 2): \& } \& \& pderror("error msg"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The purpose of this module is to provide a useful framework to produce debugging output. With this module you can assign a level of detail to pdebug statements, and they'll only be displayed to \s-1STDERR\s0 when \s-1PDEBUG\s0 is set to that level or higher. This allows you to have your program produce varying levels of debugging output. .PP Using the \fBpIn\fR and \fBpOut\fR functions at the beginning and end of each function will cause debugging output to be indented appropriately so you can visually see the level of recursion. .PP \&\fB\s-1NOTE:\s0\fR All modules within the Paranoid framework use this module. Their debug levels range from 9 and up. You should use 1 \- 8 for your own modules or code. .SS "\s-1EXPORT TARGETS\s0" .IX Subsection "EXPORT TARGETS" Only \fI\s-1PDEBUG\s0\fR, \fIpdebug\fR, \fIpIn\fR, and \fIpOut\fR are exported by default. All other functions and constants can be exported with the \fI:all\fR tag set. .SH "SUBROUTINES/METHODS" .IX Header "SUBROUTINES/METHODS" .SS "\s-1PDEBUG\s0" .IX Subsection "PDEBUG" \&\fB\s-1PDEBUG\s0\fR is an lvalue subroutine which is initially set to 0, but can be set to any positive integer. The higher the number the more pdebug statements are printed. .SS "\s-1PDMAXINDENT\s0" .IX Subsection "PDMAXINDENT" \&\fB\s-1PDMAXINDENT\s0\fR is an lvalue subroutine which is initially set to 60, but can be set to any integer. This controls the max indentation of the debug messages. Obviously, it wouldn't help to indent a debug message by a hundred columns on an eighty column terminal just because your stack depth gets that deep. .SS "\s-1PDPREFIX\s0" .IX Subsection "PDPREFIX" \&\fB\s-1PDPREFIX\s0\fR is also an lvalue subroutine and is set by default to a subroutine that returns as a string the standard prefix for debug messages: .PP .Vb 1 \& [PID \- DLEVEL] Subroutine: .Ve .PP Assigning another reference to a subroutine or string can override this behavior. .SS "pderror" .IX Subsection "pderror" .Vb 1 \& pderror("error msg"); .Ve .PP This function prints the passed message to \s-1STDERR.\s0 .SS "pdebug" .IX Subsection "pdebug" .Vb 2 \& pdebug("debug statement", 3); \& pdebug("debug statement: %s %2d %.3f", 3, @values); .Ve .PP This function is called with one mandatory argument (the string to be printed), and an optional integer. This integer is compared against \fB\s-1PDEBUG\s0\fR and the debug statement is printed if \s-1PDEBUG\s0 is equal to it or higher. .PP The return value is always the debug statement itself. This allows for a single statement to produce debug output and set variables. For instance: .PP .Vb 1 \& Paranoid::ERROR = pdebug("Something bad happened!", 3); .Ve .PP As an added benefit you can pass a printf template along with their values and they will be handled appropriately. String values passed as \fBundef\fR will be replaced with the literal string "\fIundef\fR". .PP One deviation from printf allows you to specify a placeholder which can gobble up any number of extra arguments while still performing the "\fIundef\fR" substitution: .PP .Vb 1 \& pdebug("I was passed these values: %s", 3, @values); .Ve .SS "pIn" .IX Subsection "pIn" .Vb 1 \& pIn(); .Ve .PP This function causes all subsequent pdebug messages to be indented by one additional space. .SS "pOut" .IX Subsection "pOut" .Vb 1 \& pOut(); .Ve .PP This function causes all subsequent pdebug messages to be indented by one less space. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" Paranoid .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" \&\fBpderror\fR (and by extension, \fBpdebug\fR) will generate errors if \s-1STDERR\s0 is closed elsewhere in the program. .SH "AUTHOR" .IX Header "AUTHOR" Arthur Corliss (corliss@digitalmages.com) .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. .PP (c) 2005 \- 2017, Arthur Corliss (corliss@digitalmages.com)