blib/lib/HTTP/OAI/Debug.pm

filter: Statementstmt 55.5% 20 / 36 Branchbran 12.5% 2 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 0.0% 0 / 5 totaltotal 41.5% 27 / 65 CC 11 SCAR 22.4
CC
11
Cov
42%
level
24.7
debug
6.0
conns
6.0
CRAP 9.4
« blib/lib/HTTP/OAI/ListSets.pm ↑ Summary blib/lib/HTTP/OAI/Set.pm »
1 package HTTP::OAI::Debug;
2  
3 =pod
4  
5 =head1 NAME
6  
7 B<HTTP::OAI::Debug> - debug the HTTP::OAI libraries
8  
9 =head1 DESCRIPTION
10  
11 This package is a copy of L<LWP::Debug> and exposes the same API. In addition to "trace", "debug" and "conns" this exposes a "sax" level for debugging SAX events.
12  
13 =cut
14  
15 11 require Exporter;
16 11 @ISA = qw(Exporter);
17 11 @EXPORT_OK = qw(level trace debug conns);
18  
19 11 our $VERSION = '4.11';
20  
21 11 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 11 my @levels = qw(trace debug conns sax);
24 11 %current_level = ();
25  
26  
27 sub import
28 {
29 11 ▶ my $pack = shift;
Subroutine import: called CC=3 SCAR=13.0
30 11 my $callpkg = caller(0);
31 11 my @symbols = ();
32 11 my @levels = ();
33 11 for (@_) {
34 0 ▶ if (/^[-+]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^[-+]/) { } 0 0 0
35 0 push(@levels, $_);
36 }
37 else {
38 0 push(@symbols, $_);
39 }
40 }
41 11 Exporter::export($pack, $callpkg, @symbols);
42 11 level(@levels);
43 }
44  
45  
46 sub level
47 {
48 11 ▶ for (@_) {
Subroutine level: called CC=5 SCAR=32.1
Pod undocumented
49 0 ▶ if ($_ eq '+') { # all on
Branch: 3 branches
BranchTrueFalseTotal
if ($_ eq '+') { } 0 0 0
elsif ($_ eq '-') { } 0 0 0
elsif (/^([-+])(\w+)$/) { } 0 0 0
50 # switch on all levels
51 0 %current_level = map { $_ => 1 } @levels;
52 }
53 elsif ($_ eq '-') { # all off
54 0 %current_level = ();
55 }
56 elsif (/^([-+])(\w+)$/) {
57 0 $current_level{$2} = $1 eq '+';
58 }
59 else {
60 0 Carp::croak("Illegal level format $_");
61 }
62 }
63 }
64  
65  
66 22 ▶sub trace { _log(@_) if $current_level{'trace'}; }
Subroutine trace: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $current_level{"trace"} 0 22 22
67 0 ▶sub debug { _log(@_) if $current_level{'debug'}; }
Subroutine debug: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $current_level{"debug"} 0 0 0
68 0 ▶sub conns { _log(@_) if $current_level{'conns'}; }
Subroutine conns: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $current_level{"conns"} 0 0 0
69 1289 ▶sub sax { _log(@_) if $current_level{'sax'}; }
Subroutine sax: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $current_level{"sax"} 0 1289 1289
70  
71  
72 sub _log
73 {
74 0 ▶ my $msg = shift;
Subroutine _log: not called CC=1 SCAR=6.9
75 0 $msg =~ s/\n$//;
76 0 $msg =~ s/\n/\\n/g;
77  
78 0 my($package,$filename,$line,$sub) = caller(2);
79 0 print STDERR "$sub: $msg\n";
80 }
81  
82 11 1;
« blib/lib/HTTP/OAI/ListSets.pm ↑ Summary blib/lib/HTTP/OAI/Set.pm »