GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PARANOID::DEBUG (3)

.ds Aq ’

NAME

Paranoid::Debug - Trace message support for paranoid programs

CONTENTS

VERSION

$Id: Debug.pm,v 0.93 2010/06/03 18:58:30 acorliss Exp $

SYNOPSIS



  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):
  }

  perror("error msg");

  # Deprecated
  psetDebug(@ARGV);



DESCRIPTION

The purpose of this module is to provide a barely 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 when PDEBUG is set to that level or higher. This allows you to have your program produce varying levels of debugging output.

Using the <B>pInB> and <B>pOutB> 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.

<B>NOTE:B> This module provides a function called <B>perrorB> which conflicts with a similar function provided by the <B>POSIXB> module. If you use this module you should avoid using or importing POSIX’s version of this function.

<B>NOTE:B> 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.

SUBROUTINES/METHODS

    PDEBUG

<B>PDEBUGB> is an lvalue subroutine which is initially set to 0, but can be set to any positive integer. The higher the number the higher the level of pdebug statements are printed.

    PDMAXINDENT

<B>PDMAXINDENTB> 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.

    PDPREFIX

<B>PDPREFIXB> is also an lvalue subroutien and is set by default to a subroutine that returns as a string the standard prefix for debug messages:



  [PID - DLEVEL] Subroutine:



Assigning another subroutine reference to a subroutine can override this behavior.

    perror



  perror("error msg");



This function prints the passed message to STDERR.

    pdebug



  pdebug("debug statement", 3);



This function is called with one mandatory argument (the string to be printed), and an optional integer. This integer is compared against <B>PDEBUGB> and the debug statement is printed if PDEBUG is equal to it or higher.

The return value is always the debug statement itself. This allows for a single statement to produce debug output and set variables. For instance:



  Paranoid::ERROR = pdebug("Something bad happened!", 3);



    pIn



  pIn();



This function causes all subsequent pdebug messages to be indented by one additional space.

    pOut



  pOut();



This function causes all subsequent pdebug messages to be indented by one less space.

    psetDebug



  psetDebug(@ARGV);



This function extracts all ^-v+$ arguments from the passed list and counts the number of ’v’s that result, and sets <B>PDEBUGB> to that count. You would typically use this by passing @ARGV for command-line programs.

<B>NOTEB>: This was a dumb idea of incredible proportions. As soons as it is safe to do so I will kill this function and perform my penance before the gods of bitrot. Consider this deprecated.

DEPENDENCIES

Paranoid

BUGS AND LIMITATIONS

<B>perrorB> (and by extension, <B>pdebugB>) will generate errors if STDERR is closed elsewhere in the program.

There is also no upper limit on how much indentation will be used by the program, so if you’re using <B>pInB> in deeply recursive call stacks you can expect some overhead due some rather large strings being bandied about.

AUTHOR

(c) 2005 Arthur Corliss (corliss@digitalmages.com)

LICENSE AND COPYRIGHT

This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.

(c) 2005, Arthur Corliss (corliss@digitalmages.com)

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PARANOID::DEBUG (3) 2010-06-03

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.