| Summary | Package variables | Synopsis | Description | General documentation | Methods |
| Summary | Top |
package Clair::Debug |
| Package variables | Top |
| No package variables defined. |
| Included modules | Top |
| Data::Dumper |
| Synopsis | Top |
This module Exports simple functions to all other classes for debug
message printing.
In other modules that need debug or informational message printing, do
use vars qw/$DEBUG/;
use Clair::Debug;
And call one of these two functions after instantiating the object:
$self->debugmsg("test msg", 1); # only prints if $DEBUG is set > 1.
$self->errmsg("test msg", 1); # dies after printing msg. |
| Description | Top |
Other perl objects will use this module for printing debug messages according to the debug level. Designed to standardize the debug printing as well as other useful messages out to STDOUT. Other instantiated objects can access these methods simply from its own namespace (symbol table). |
| Methods | Top |
| BEGIN | Code | |
| _process_msg | Description | Code |
| debugmsg | Description | Code |
| errmsg | Description | Code |
| _process_msg | code | next | Top |
Private subroutine that determines the datatype of $msg (type of reference) and returns it in scalar format. This function, too, needs to be exported so that other classes can fully use $self->debugmsg() and $self->errmsg() functions. |
| debugmsg | code | prev | next | Top |
Takes in a message and prints according to the current global debug level. The caller object and subroutine is specified within the brakets []. |
| errmsg | code | prev | next | Top |
Similar to the $self->debugmsg() subroutine above. Instead of merely printing the debug message, this function will issue a 'die' call at the end of the second argument is true. |
| BEGIN | Top |
BEGIN {use Exporter(); @Clair::Debug::ISA = qw(Exporter); @Clair::Debug::EXPORT = qw(&debugmsg &errmsg &_process_msg $DEBUG); # @Clair::Debug::EXPORT_OK = qw($DEBUG);} |
| _process_msg | description | prev | next | Top |
sub _process_msg
{my ($self, $msg) = @_; my $type = ref $msg; my $returnmsg = (! $type || $type eq "SCALAR") ? $msg : Dumper($msg); return $returnmsg;} |
| debugmsg | description | prev | next | Top |
sub debugmsg
{my ($self, $msg, $debuglevel) = @_; # caller routine contains the blessed object name and its subroutine} |
| errmsg | description | prev | next | Top |
sub errmsg
{
my ($self, $msg, $die) = @_;
my @caller_meta = caller(1);
my $caller_tok = $caller_meta[3] || $0;
my $returnmsg = $self->_process_msg($msg);
$msg = "[FATAL $caller_tok] $returnmsg\n";
if($die)
{
die $msg;
}
return $msg;} |
| AUTHOR | Top |
JB Kim jbremnant@gmail.com |
| EXPORTS | Top |
exports &debugmsg($msg, $debuglevel) and &errmsg($msg, $die) |