File Coverage

lib/Sub/Contract/Debug.pm
Criterion Covered Total %
statement 14 18 77.7
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 26 80.7


line stmt bran cond sub pod time code
1             #
2             # Sub::Contract::Debug - Guess once...
3             #
4             # $Id: Debug.pm,v 1.11 2009/06/16 12:23:58 erwan_lemonnier Exp $
5             #
6              
7             package Sub::Contract::Debug;
8              
9 22     22   30231 use strict;
  22         42  
  22         5001  
10 22     22   114 use warnings;
  22         40  
  22         963  
11 22     22   113 use Carp qw(croak);
  22         48  
  22         1152  
12              
13 22     22   148 use base qw(Exporter);
  22         40  
  22         26982  
14              
15             our $VERSION = '0.12';
16              
17             our @EXPORT = ();
18             our @EXPORT_OK = ('debug');
19              
20             # to turn on debugging output in Sub::Contract, just
21             # set $DEBUG to more than 0:
22              
23             my $DEBUG = 0;
24              
25             #---------------------------------------------------------------
26             #
27             # debug - print a debug message to stdout
28             #
29              
30             sub debug {
31 127     127 1 214 my ($level,$text) = @_;
32              
33 127 50       472 if ($level <= $DEBUG) {
34 0           chomp $text;
35 0           my (undef, undef, $line) = caller(0);
36 0           my (undef, undef, undef, $func) = caller(1);
37 0           print "# DEBUG $func, l.".sprintf("%- 5s","$line:")." $text\n";
38             }
39             }
40              
41             1;
42              
43             __END__