lib/FindApp/Utils/Debug.pm

filter: Statementstmt 65.7% 75 / 114 Branchbran 19.4% 7 / 36 Conditioncond 13.0% 3 / 23 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 75.0% 18 / 24 Podpod 100% 5 / 5 totaltotal 49.7% 108 / 217 CC 27 SCAR 17.8
CC
27
Cov
49%
tracing
12.0
debugging
12.0
ENTER_TRACE_1
7.4
CRAP 5.9
« blib/lib/FindApp/Utils/List.pm ↑ Summary blib/lib/FindApp/Object/State/Group/State.pm »
1 package FindApp::Utils::Debug;
2  
3 6 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 6 ▶use Carp qw(carp croak cluck confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use File::Spec qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶use FindApp::Vars qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use FindApp::Utils::Assert qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use FindApp::Utils::Syntax qw( function );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use FindApp::Utils::Foreign qw( abs2rel );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use FindApp::Utils::Objects qw( class_prune );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #################################################################
18  
19 6 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 our $VERSION = 1.0;
21 4 our @EXPORT_OK = (
22 <ENTER_TRACE{,_{1,2,3,4,5}}>,
23 qw(
24 debug
25 debugging
26 tracing
27 ),
28 );
29 4 our %EXPORT_TAGS = (
30 all => \@EXPORT_OK,
31 );
32  
33 #################################################################
34  
35 sub debug ;
36 sub debugging ;
37 sub hail_mary ;
38 sub safety_net ;
39 sub tracing ;
40  
41 sub ENTER_TRACE ;
42 sub ENTER_TRACE_1 ;
43 sub ENTER_TRACE_2 ;
44 sub ENTER_TRACE_3 ;
45 sub ENTER_TRACE_4 ;
46 sub ENTER_TRACE_5 ;
47  
48 #################################################################
49  
50 sub tracing {
51 0 ▶ my $self = shift;
Subroutine tracing: not called CC=3 SCAR=24.8
Pod documented
52 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
53 0 $Tracing = shift;
54 0 ▶ safety_net($Debugging || $Tracing);
Condition0%0/3
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
l!l&&r!l&&!r
000
MC/DC0%0/2
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
$FindApp::Utils::Debug::Debugging $FindApp::Utils::Debug::Tracing
Truth table0%0/3
A || B
A= $FindApp::Utils::Debug::DebuggingB= $FindApp::Utils::Debug::Tracing
ABresult
1X1
011
000
55 }
56 0 return $Tracing;
57 }
58  
59 sub debug {
60 26 ▶ return unless $Debugging;
Subroutine debug: called CC=3 SCAR=16.3
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless $FindApp::Utils::Debug::Debugging 26 0 26
61 0 my($pack, $file, $line, $sub) = caller(0);
62 0 $file = abs2rel($file);
63 6 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 0 ▶ my $suffix = $Debugging > 1 && " at $file line $line";
Condition0%0/2
$FindApp::Utils::Debug::Debugging > 1 && " at $file line $line"
!ll
00
MC/DC0%0/1
$FindApp::Utils::Debug::Debugging > 1 && " at $file line $line"
$FindApp::Utils::Debug::Debugging > 1
Truth table0%0/2
A
A= $FindApp::Utils::Debug::Debugging > 1
Aresult
00
11
65 0 local @SIG{<__{WARN,DIE}__>};
66 0 print STDERR "@_$suffix\n";
67 }
68  
69 sub safety_net {
70 0 ▶ my($enable) = @_;
Subroutine safety_net: not called CC=2 SCAR=17.9
Pod documented
71 0 ▶ $SIG{__DIE__} = $enable ? \&hail_mary : undef;
Branch: 1 branch
BranchTrueFalseTotal
$enable ? : 0 0 0
72 }
73  
74 sub debugging {
75 0 ▶ my $self = shift;
Subroutine debugging: not called CC=3 SCAR=24.8
Pod documented
76 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
77 0 $Debugging = shift;
78 0 ▶ safety_net($Debugging || $Tracing);
Condition0%0/3
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
l!l&&r!l&&!r
000
MC/DC0%0/2
$FindApp::Utils::Debug::Debugging || $FindApp::Utils::Debug::Tracing
$FindApp::Utils::Debug::Debugging $FindApp::Utils::Debug::Tracing
Truth table0%0/3
A || B
A= $FindApp::Utils::Debug::DebuggingB= $FindApp::Utils::Debug::Tracing
ABresult
1X1
011
000
79 }
80 0 return $Debugging;
81 }
82  
83 sub hail_mary {
84 0 ▶ return if $^S;
Subroutine hail_mary: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $^S 0 0 0
85 0 local @SIG{<__{WARN,DIE}__>};
86 0 confess "caught exception: @_";
87 }
88  
89 #################################################################
90  
91 4 for my $func (<debugging tracing>) {
92 6 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
93 8 my $var = ucfirst $func;
94 8 ▶ $func->($$var) if $$var;
Branch: 1 branch
BranchTrueFalseTotal
if $$var 0 8 8
95 }
96  
97 4 for my $LEVEL (1 .. 5) {
98 function "ENTER_TRACE_${LEVEL}" => sub {
99 1073 ▶ return unless $Tracing && $Tracing >= $LEVEL;
Subroutine ENTER_TRACE_5: called CC=4 SCAR=20.0
Subroutine ENTER_TRACE_3: called CC=4 SCAR=20.0
Subroutine __ANON__: called CC=4 SCAR=20.0
Subroutine ENTER_TRACE_4: not called CC=4 SCAR=20.0
Subroutine ENTER_TRACE_1: not called CC=4 SCAR=20.0
Branch: 6 branches
BranchTrueFalseTotal
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 1073 0 1073
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 464 0 464
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 2 2
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
unless $FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL 0 0 0
Condition20%3/15
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
107300
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
46400
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
46400
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
000
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
!ll&&!rl&&r
000
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
MC/DC0%0/2
$FindApp::Utils::Debug::Tracing and $FindApp::Utils::Debug::Tracing >= $LEVEL
$FindApp::Utils::Debug::Tracing $FindApp::Utils::Debug::Tracing >= $LEVEL
Truth table33%1/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $FindApp::Utils::Debug::TracingB= $FindApp::Utils::Debug::Tracing >= $LEVEL
ABresult
0X0
100
111
100 0 my($pack, $file, $line, $sub) = caller(1);
101 0 $file = abs2rel($file);
102 6 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 0 local @SIG{<__{WARN,DIE}__>};
104 0 ▶ my @safe_args = map { defined() ? $_ : "(undef)" } @_;
Branch: 6 branches
BranchTrueFalseTotal
defined $_ ? : 0 0 0
defined $_ ? : 0 0 0
defined $_ ? : 464 0 464
defined $_ ? : 0 2 2
defined $_ ? : 0 0 0
defined $_ ? : 0 0 0
105 0 print STDERR class_prune "$sub @safe_args\n";
106 }
107 20 }
108  
109 4 *ENTER_TRACE = \&ENTER_TRACE_1;
110  
111 4 1;
112  
113 =encoding utf8
114  
115 =head1 NAME
116  
117 FindApp::Utils::Debug - FIXME
118  
119 =head1 SYNOPSIS
120  
121 use FindApp::Utils::Debug;
122  
123 =head1 DESCRIPTION
124  
125 =head2 Exports
126  
127 =over
128  
129 =item ENTER_TRACE
130  
131 =item ENTER_TRACE_1
132  
133 =item ENTER_TRACE_2
134  
135 =item ENTER_TRACE_3
136  
137 =item ENTER_TRACE_4
138  
139 =item ENTER_TRACE_5
140  
141 =item debug
142  
143 =item debugging
144  
145 =item hail_mary
146  
147 =item safety_net
148  
149 =item tracing
150  
151 =back
152  
153 =head1 EXAMPLES
154  
155 =head1 ENVIRONMENT
156  
157 =head1 SEE ALSO
158  
159 =over
160  
161 =item L<FindApp>
162  
163 =back
164  
165 =head1 CAVEATS AND PROVISOS
166  
167 =head1 BUGS AND LIMITATIONS
168  
169 =head1 HISTORY
170  
171 =head1 AUTHOR
172  
173 Tom Christiansen << <tchrist@perl.com> >>
174  
175 =head1 LICENCE AND COPYRIGHT
176  
177 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
178 All Rights Reserved.
179  
180 This module is free software; you can redistribute it and/or
181 modify it under the same terms as Perl itself. See L<perlartistic>.
182  
183 =cut
184  
« blib/lib/FindApp/Utils/List.pm ↑ Summary blib/lib/FindApp/Object/State/Group/State.pm »