ger/Heavy.pm

filter: Statementstmt 79.9% 175 / 219 Branchbran 55.4% 51 / 92 Conditioncond 34.2% 25 / 73 MC/DCmcdc 11.3% 5 / 44 Subroutinesub 57.6% 15 / 26 Podpod 0.0% 0 / 2 totaltotal 59.4% 271 / 456 CC 82 SCAR 36.4
CC
82
Cov
65%
init_target
106.8
__ANON__
20.5
run_hooks
14.4
CRAP 38.1
↑ Summary ger/Util.pm »
1 ## no critic: TestingAndDebugging::RequireUseStrict
2 package Log::ger::Heavy;
3  
4 11 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
5 11 our $DATE = '2023-12-29'; # DATE
6 11 our $DIST = 'Log-ger'; # DIST
7 11 our $VERSION = '0.042'; # VERSION
8  
9 #IFUNBUILT
10 # use strict;
11 # use warnings;
12 #END IFUNBUILT
13  
14 package
15 Log::ger;
16  
17 #IFUNBUILT
18 # our (
19 # $re_addr,
20 # %Levels,
21 # %Level_Aliases,
22 # $Current_Level,
23 # $_outputter_is_null,
24 # $_dumper,
25 # %Global_Hooks,
26 # %Package_Targets,
27 # %Per_Package_Hooks,
28 # %Hash_Targets,
29 # %Per_Hash_Hooks,
30 # %Object_Targets,
31 # %Per_Object_Hooks,
32 # );
33 #END IFUNBUILT
34  
35 # key = phase, value = [ [key, prio, coderef], ... ]
36 our %Default_Hooks = (
37 create_filter => [],
38  
39 create_formatter => [
40 [__PACKAGE__, 90,
41 51 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=2.5
42 51 my %args = @_;
43  
44 # BEGIN_BLOCK: default_formatter
45  
46 my $formatter =
47  
48 # the default formatter is sprintf-style that dumps data
49 # structures arguments as well as undef as '<undef>'.
50 32 ▶ sub {
Subroutine __ANON__: called CC=6 SCAR=30.2
51 32 ▶ return $_[0] if @_ < 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 2 32 0 32
52 0 my $fmt = shift;
53 0 my @args;
54 0 for (@_) {
55 0 ▶ if (!defined($_)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_) { } 0 0 0
elsif (ref $_) { } 0 0 0
56 0 push @args, '<undef>';
57 } elsif (ref $_) {
58 0 ▶ require Log::ger::Util unless $Log::ger::_dumper;
Branch: 1 branch
BranchTrueFalseTotal
unless $_dumper 0 0 0
59 0 push @args, Log::ger::Util::_dump($_);
60 } else {
61 0 push @args, $_;
62 }
63 }
64 # redefine is just a dummy category for perls < 5.22 which
65 # don't have 'redundant' yet
66 11 ▶ no warnings ($warnings::Bits{'redundant'} ? 'redundant' : 'redefine');
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$warnings::Bits{'redundant'} ? : 11 0 11
67 0 sprintf $fmt, @args;
68 51 };
69  
70 51 [$formatter];
71  
72 # END_BLOCK: default_formatter
73  
74 }],
75 ],
76  
77 create_layouter => [],
78  
79 create_routine_names => [
80 [__PACKAGE__, 90,
81 # the default names are log_LEVEL() and log_is_LEVEL() for subroutine
82 # names, or LEVEL() and is_LEVEL() for method names
83 51 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
84 51 my %args = @_;
85  
86 51 my $levels = [keys %Levels];
87  
88 return [{
89 306 logger_subs => [map { ["log_$_", $_] } @$levels],
90 306 level_checker_subs => [map { ["log_is_$_", $_] } @$levels],
91 # used when installing to hash or object
92 306 logger_methods => [map { ["$_", $_] } @$levels],
93 51 level_checker_methods => [map { ["is_$_", $_] } @$levels],
94 }, 1];
95 }],
96 ],
97  
98 # old name for create_outputter, deprecated and will be removed in the
99 # future
100 create_log_routine => [],
101  
102 create_outputter => [
103 [__PACKAGE__, 10,
104 # the default behavior is to create a null routine for levels that are
105 # too high than the global level ($Current_Level). since we run at high
106 # priority (10), we block typical output plugins at normal priority
107 # (50). this is a convenience so normally a plugin does not have to
108 # deal with level checking. plugins that want to do its own level
109 # checking can use a higher priority.
110 308 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
111 308 my %args = @_;
112 308 my $level = $args{level};
113 308 my $num_outputs = 0;
114 308 $num_outputs += @{ $Global_Hooks{create_log_routine} }; # old name, will be removed
115 308 $num_outputs += @{ $Global_Hooks{create_outputter} };
116 308 ▶ if ( # level indicates routine should be a null logger
Branch: 1 branch
BranchTrueFalseTotal
if (defined $level and $Current_Level < $level or $num_outputs == 1) 113 195 308
Condition83%5/6
defined $level and $Current_Level < $level or $num_outputs == 1
l!l&&r!l&&!r
1130195
defined $level and $Current_Level < $level
!ll&&!rl&&r
2193113
MC/DC66%2/3
defined $level and $Current_Level < $level or $num_outputs == 1
defined $level $Current_Level < $level $num_outputs == 1
Truth table60%3/5
A and B or C
A= defined $levelB= $Current_Level < $levelC= $num_outputs == 1
ABCresult
11X1
0X11
1011
0X00
1000
117 (defined $level && $Current_Level < $level) ||
118 # there's only us that produces log routines (e.g. no outputs)
119 $num_outputs == 1
120 ) {
121 113 $_outputter_is_null = 1;
122 113 ▶ return [sub {0}];
Subroutine __ANON__: called CC=1 SCAR=0.0
123 }
124 195 [undef]; # decline, let output plugin supply logger routines
125 }],
126 ],
127  
128 # old name for create_level_checker, deprecated and will be removed in the
129 # future
130 create_is_routine => [],
131  
132 create_level_checker => [
133 [__PACKAGE__, 90,
134 # the default behavior is to compare to global level. normally this
135 # behavior suffices. we run at low priority (90) so normal plugins
136 # which typically use priority 50 can override us.
137 306 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.6
138 306 my %args = @_;
139 306 my $level = $args{level};
140 0 ▶ [sub { $Current_Level >= $level }];
Subroutine __ANON__: not called CC=1 SCAR=2.6
Subroutine is_trace: not called CC=1 SCAR=2.6
141 11 }],
142 ],
143  
144 before_install_routines => [],
145  
146 after_install_routines => [],
147 );
148  
149 11 for my $phase (keys %Default_Hooks) {
150 110 $Global_Hooks{$phase} = [@{ $Default_Hooks{$phase} }];
151 }
152  
153 # if flow_control is 1, stops after the first hook that gives non-undef result.
154 # flow_control can also be a coderef that will be called after each hook with
155 # ($hook, $hook_res) and can return 1 to mean stop.
156 1226 ▶sub run_hooks {
Subroutine run_hooks: called CC=14 SCAR=26.7
Pod undocumented
157 1226 my ($phase, $hook_args, $flow_control,
158 $target_type, $target_name) = @_;
159 #print "D: running hooks for phase $phase\n";
160  
161 1226 ▶ $Global_Hooks{$phase} or die "Unknown phase '$phase'";
Branch: 1 branch
BranchTrueFalseTotal
$Global_Hooks{$phase} or die "Unknown phase '${phase}'" 1226 0 1226
162 1226 my @hooks = @{ $Global_Hooks{$phase} };
163  
164 1226 ▶ if ($target_type eq 'package') {
Branch: 3 branches
BranchTrueFalseTotal
if ($target_type eq 'package') { } 506 720 1226
elsif ($target_type eq 'hash') { } 120 600 720
elsif ($target_type eq 'object') { } 600 0 600
165 506 ▶ unshift @hooks, @{ $Per_Package_Hooks{$target_name}{$phase} || [] };
Condition100%2/2
$Per_Package_Hooks{$target_name}{$phase} || []
l!l
6500
MC/DC100%1/1
$Per_Package_Hooks{$target_name}{$phase} || []
$Per_Package_Hooks{$target_name}{$phase}
Truth table100%2/2
A
A= $Per_Package_Hooks{$target_name}{$phase}
Aresult
11
00
166 } elsif ($target_type eq 'hash') {
167 120 my ($addr) = "$target_name" =~ $re_addr;
168 120 ▶ unshift @hooks, @{ $Per_Hash_Hooks{$addr}{$phase} || [] };
Condition50%1/2
$Per_Hash_Hooks{$addr}{$phase} || []
l!l
0120
MC/DC0%0/1
$Per_Hash_Hooks{$addr}{$phase} || []
$Per_Hash_Hooks{$addr}{$phase}
Truth table50%1/2
A
A= $Per_Hash_Hooks{$addr}{$phase}
Aresult
11
00
169 } elsif ($target_type eq 'object') {
170 600 my ($addr) = "$target_name" =~ $re_addr;
171 600 ▶ unshift @hooks, @{ $Per_Object_Hooks{$addr}{$phase} || [] };
Condition50%1/2
$Per_Object_Hooks{$addr}{$phase} || []
l!l
0600
MC/DC0%0/1
$Per_Object_Hooks{$addr}{$phase} || []
$Per_Object_Hooks{$addr}{$phase}
Truth table50%1/2
A
A= $Per_Object_Hooks{$addr}{$phase}
Aresult
11
00
172 }
173  
174 1226 my $res;
175 1226 for my $hook (sort {$a->[1] <=> $b->[1]} @hooks) {
176 917 my $hook_res = $hook->[2]->(%$hook_args);
177 917 ▶ if (defined $hook_res->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hook_res->[0]) 722 195 917
178 722 $res = $hook_res->[0];
179 #print "D: got result from hook $hook->[0]: $res\n";
180 722 ▶ if (ref $flow_control eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $flow_control eq 'CODE') { } 108 614 722
181 108 ▶ last if $flow_control->($hook, $hook_res);
Branch: 1 branch
BranchTrueFalseTotal
if &$flow_control($hook, $hook_res) 51 57 108
182 } else {
183 614 ▶ last if $flow_control;
Branch: 1 branch
BranchTrueFalseTotal
if $flow_control 614 0 614
184 }
185 }
186 252 ▶ last if $hook_res->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $hook_res->[1] 0 252 252
187 }
188 1226 return $res;
189 }
190  
191 51 ▶sub init_target {
Subroutine init_target: called CC=34 SCAR=46.7
Pod undocumented
192 51 my ($target_type, $target_name, $per_target_conf) = @_;
193  
194 #print "D:init_target($target_type, $target_name, ...)\n";
195 51 my %hook_args = (
196 target_type => $target_type,
197 target_name => $target_name,
198 per_target_conf => $per_target_conf,
199 );
200  
201 # collect only a single filter
202 51 my %filters;
203 run_hooks(
204 'create_filter', \%hook_args,
205 # collect filters, until a hook instructs to stop
206 2 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.8
207 2 my ($hook, $hook_res) = @_;
208 2 my ($filter, $flow_control, $fltname) = @$hook_res;
209 2 ▶ $fltname = 'default' if !defined($fltname);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fltname 0 2 2
210 2 ▶ $filters{$fltname} ||= $filter;
Condition33%1/3
$filters{$fltname} ||= $filter
l!l&&r!l&&!r
020
MC/DC0%0/2
$filters{$fltname} ||= $filter
$filters{$fltname} $filter
Truth table33%1/3
A ||= B
A= $filters{$fltname}B= $filter
ABresult
1X1
011
000
211 2 $flow_control;
212 },
213 51 $target_type, $target_name);
214  
215 51 my %formatters;
216 run_hooks(
217 'create_formatter', \%hook_args,
218 # collect formatters, until a hook instructs to stop
219 53 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
220 53 my ($hook, $hook_res) = @_;
221 53 my ($formatter, $flow_control, $fmtname) = @$hook_res;
222 53 ▶ $fmtname = 'default' if !defined($fmtname);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fmtname 51 2 53
223 53 ▶ $formatters{$fmtname} ||= $formatter;
Condition33%1/3
$formatters{$fmtname} ||= $formatter
l!l&&r!l&&!r
0530
MC/DC0%0/2
$formatters{$fmtname} ||= $formatter
$formatters{$fmtname} $formatter
Truth table33%1/3
A ||= B
A= $formatters{$fmtname}B= $formatter
ABresult
1X1
011
000
224 53 $flow_control;
225 },
226 51 $target_type, $target_name);
227  
228 # collect only a single layouter
229 51 my $layouter =
230 run_hooks(
231 'create_layouter', \%hook_args, 1, $target_type, $target_name);
232  
233 51 my $routine_names = {};
234 run_hooks(
235 'create_routine_names', \%hook_args,
236 # collect routine names, until a hook instructs to stop.
237 53 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
238 53 my ($hook, $hook_res) = @_;
239 53 my ($routine_name_rec, $flow_control) = @$hook_res;
240 53 ▶ $routine_name_rec or return;
Branch: 1 branch
BranchTrueFalseTotal
$routine_name_rec or return 53 0 53
241 53 for (keys %$routine_name_rec) {
242 208 push @{ $routine_names->{$_} }, @{ $routine_name_rec->{$_} };
243 }
244 53 $flow_control;
245 },
246 51 $target_type, $target_name);
247  
248 51 my @routines;
249 51 my $is_object = $target_type eq 'object';
250  
251 CREATE_LOGGER_ROUTINES:
252 {
253 51 my @routine_name_recs;
254 51 ▶ if ($target_type eq 'package') {
Branch: 1 branch
BranchTrueFalseTotal
if ($target_type eq 'package') { } 21 30 51
255 21 ▶ push @routine_name_recs, @{ $routine_names->{log_subs} || [] }; # old name, will be removed
Condition50%1/2
$routine_names->{'log_subs'} || []
l!l
021
MC/DC0%0/1
$routine_names->{'log_subs'} || []
$routine_names->{'log_subs'}
Truth table50%1/2
A
A= $routine_names->{'log_subs'}
Aresult
11
00
256 21 ▶ push @routine_name_recs, @{ $routine_names->{logger_subs} || [] };
Condition50%1/2
$routine_names->{'logger_subs'} || []
l!l
210
MC/DC0%0/1
$routine_names->{'logger_subs'} || []
$routine_names->{'logger_subs'}
Truth table50%1/2
A
A= $routine_names->{'logger_subs'}
Aresult
11
00
257 } else {
258 30 ▶ push @routine_name_recs, @{ $routine_names->{log_methods} || [] }; # old name, will be removed
Condition50%1/2
$routine_names->{'log_methods'} || []
l!l
030
MC/DC0%0/1
$routine_names->{'log_methods'} || []
$routine_names->{'log_methods'}
Truth table50%1/2
A
A= $routine_names->{'log_methods'}
Aresult
11
00
259 30 ▶ push @routine_name_recs, @{ $routine_names->{logger_methods} || [] };
Condition50%1/2
$routine_names->{'logger_methods'} || []
l!l
300
MC/DC0%0/1
$routine_names->{'logger_methods'} || []
$routine_names->{'logger_methods'}
Truth table50%1/2
A
A= $routine_names->{'logger_methods'}
Aresult
11
00
260 }
261 NAME:
262 51 for my $routine_name_rec (@routine_name_recs) {
263 308 my ($rname, $lname, $fmtname, $rper_target_conf, $fltname)
264 = @$routine_name_rec;
265 308 ▶ my $lnum; $lnum = $Levels{$lname} if defined $lname;
Branch: 1 branch
BranchTrueFalseTotal
if defined $lname 306 2 308
266 308 ▶ $fmtname = 'default' if !defined($fmtname);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fmtname 306 2 308
267  
268 308 my ($output_routine, $logger);
269 308 $_outputter_is_null = 0;
270 308 local $hook_args{name} = $rname; # compat, deprecated
271 308 local $hook_args{routine_name} = $rname;
272 308 local $hook_args{level} = $lnum;
273 308 local $hook_args{str_level} = $lname;
274 308 my $outputter;
275 {
276 308 ▶ $outputter = run_hooks("create_outputter" , \%hook_args, 1, $target_type, $target_name) and last;
Branch: 1 branch
BranchTrueFalseTotal
$outputter = run_hooks("create_outputter", \%hook_args, 1, $target_type, $target_name) and last 308 0 308
277 0 $outputter = run_hooks("create_log_routine", \%hook_args, 1, $target_type, $target_name); # old name, will be removed in the future
278 }
279 308 ▶ die "BUG in configuration: No outputter is produced for routine name $rname" unless $outputter;
Branch: 1 branch
BranchTrueFalseTotal
unless $outputter 0 308 308
280  
281 { # enclosing block
282 308 ▶ if ($_outputter_is_null) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_outputter_is_null) 113 195 308
283  
284 # if outputter is a null outputter (sub {0}) we don't need
285 # to format message, layout message, or care about the
286 # logger routine being a subroutine/object. shortcut here
287 # for faster init.
288  
289 113 $logger = $outputter;
290 113 last;
291 }
292  
293 195 my $formatter = $formatters{$fmtname};
294 195 ▶ my $filter = defined($fltname) ? $filters{$fltname} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $fltname ? : 2 193 195
295  
296 # zoom out to see vertical alignments... we have filter(x2) x
297 # formatter+layouter(x3) x OO/non-OO (x2) = 12 permutations. we
298 # create specialized subroutines for each case, for performance
299 # reason.
300 0 ▶ if ($filter) { if ($formatter) { if ($layouter) { if ($is_object) { $logger = sub { shift; return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname, $per_msg_conf), $per_msg_conf) }; # has-filter has-formatter has-layouter with-oo
Subroutine __ANON__: not called CC=3 SCAR=17.3
Branch: 5 branches
BranchTrueFalseTotal
if ($filter) { } 2 193 195
if ($formatter) { } 2 0 2
if ($layouter) { } 0 2 2
if ($is_object) { } 0 0 0
unless my $per_msg_conf = &$filter(@_) 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
301 0 ▶ } else { $logger = sub { return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname, $per_msg_conf), $per_msg_conf) }; } # has-filter has-formatter has-layouter not-oo
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
unless my $per_msg_conf = &$filter(@_) 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
302 0 ▶ } else { if ($is_object) { $logger = sub { shift; return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_), $per_msg_conf) }; # has-filter has-formatter no-layouter with-oo
Subroutine __ANON__: not called CC=3 SCAR=21.1
Branch: 2 branches
BranchTrueFalseTotal
if ($is_object) { } 0 2 2
unless my $per_msg_conf = &$filter(@_) 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
303 2 ▶ } else { $logger = sub { return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_), $per_msg_conf) }; } } # has-filter has-formatter no-layouter not-oo
Subroutine __ANON__: called CC=3 SCAR=11.4
Branch: 1 branch
BranchTrueFalseTotal
unless my $per_msg_conf = &$filter(@_) 1 1 2
Condition33%1/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
010
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table33%1/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
304 0 ▶ } else { if ($is_object) { $logger = sub { shift; return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, \@_, $per_msg_conf) }; # has-filter no-formatter no-layouter with-oo
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
if ($is_object) { } 0 0 0
unless my $per_msg_conf = &$filter(@_) 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
305 0 ▶ } else { $logger = sub { return 0 unless my $per_msg_conf = $filter->(@_); $outputter->($rper_target_conf || $per_target_conf, \@_, $per_msg_conf) }; } } # has-filter no-formatter no-layouter not-oo
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
unless my $per_msg_conf = &$filter(@_) 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
306 0 ▶ } else { if ($formatter) { if ($layouter) { if ($is_object) { $logger = sub { shift; $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname ) ) }; # no-filter has-formatter has-layouter with-oo
Subroutine __ANON__: not called CC=2 SCAR=12.7
Branch: 3 branches
BranchTrueFalseTotal
if ($formatter) { } 193 0 193
if ($layouter) { } 0 193 193
if ($is_object) { } 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
307 0 ▶ } else { $logger = sub { $outputter->($rper_target_conf || $per_target_conf, $layouter->($formatter->(@_), $per_target_conf, $lnum, $lname ) ) }; } # no-filter has-formatter has-layouter not-oo
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
308 193 ▶ } else { if ($is_object) { $logger = sub { shift; $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_) ) }; # no-filter has-formatter no-layouter with-oo
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if ($is_object) { } 89 104 193
Condition33%1/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
0021
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table33%1/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
309 104 ▶ } else { $logger = sub { $outputter->($rper_target_conf || $per_target_conf, $formatter->(@_) ) }; } } # no-filter has-formatter no-layouter not-oo
Subroutine __ANON__: called CC=2 SCAR=7.1
Condition66%2/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
038
MC/DC50%1/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table66%2/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
310 0 ▶ } else { if ($is_object) { $logger = sub { shift; $outputter->($rper_target_conf || $per_target_conf, \@_ ) }; # no-filter no-formatter no-layouter with-oo
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($is_object) { } 0 0 0
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
311 0 ▶ } else { $logger = sub { $outputter->($rper_target_conf || $per_target_conf, \@_ ) }; } } } # no-filter no-formatter no-layouter not-oo
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
000
MC/DC0%0/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table0%0/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
312 } # enclosing block
313 L1:
314 308 ▶ my $rtype = $is_object ? 'logger_method' : 'logger_sub';
Branch: 1 branch
BranchTrueFalseTotal
$is_object ? : 150 158 308
315 308 ▶ push @routines, [$logger, $rname, $lnum, $rtype, $rper_target_conf||$per_target_conf];
Condition66%2/3
$rper_target_conf || $per_target_conf
l!l&&r!l&&!r
023078
MC/DC50%1/2
$rper_target_conf || $per_target_conf
$rper_target_conf $per_target_conf
Truth table66%2/3
A || B
A= $rper_target_confB= $per_target_conf
ABresult
1X1
011
000
316 }
317 }
318  
319 CREATE_LEVEL_CHECKER_ROUTINES:
320 {
321 51 my @routine_name_recs;
322 my $type;
323 51 ▶ if ($target_type eq 'package') {
Branch: 1 branch
BranchTrueFalseTotal
if ($target_type eq 'package') { } 21 30 51
324 21 ▶ push @routine_name_recs, @{ $routine_names->{is_subs} || [] }; # old name, will be removed
Condition50%1/2
$routine_names->{'is_subs'} || []
l!l
021
MC/DC0%0/1
$routine_names->{'is_subs'} || []
$routine_names->{'is_subs'}
Truth table50%1/2
A
A= $routine_names->{'is_subs'}
Aresult
11
00
325 21 ▶ push @routine_name_recs, @{ $routine_names->{level_checker_subs} || [] };
Condition50%1/2
$routine_names->{'level_checker_subs'} || []
l!l
210
MC/DC0%0/1
$routine_names->{'level_checker_subs'} || []
$routine_names->{'level_checker_subs'}
Truth table50%1/2
A
A= $routine_names->{'level_checker_subs'}
Aresult
11
00
326 21 $type = 'level_checker_sub';
327 } else {
328 30 ▶ push @routine_name_recs, @{ $routine_names->{is_methods} || [] }; # old name, will be removed
Condition50%1/2
$routine_names->{'is_methods'} || []
l!l
030
MC/DC0%0/1
$routine_names->{'is_methods'} || []
$routine_names->{'is_methods'}
Truth table50%1/2
A
A= $routine_names->{'is_methods'}
Aresult
11
00
329 30 ▶ push @routine_name_recs, @{ $routine_names->{level_checker_methods} || [] };
Condition50%1/2
$routine_names->{'level_checker_methods'} || []
l!l
300
MC/DC0%0/1
$routine_names->{'level_checker_methods'} || []
$routine_names->{'level_checker_methods'}
Truth table50%1/2
A
A= $routine_names->{'level_checker_methods'}
Aresult
11
00
330 30 $type = 'level_checker_method';
331 }
332 51 for my $routine_name_rec (@routine_name_recs) {
333 306 my ($rname, $lname) = @$routine_name_rec;
334 306 my $lnum = $Levels{$lname};
335  
336 306 local $hook_args{name} = $rname;
337 306 local $hook_args{level} = $lnum;
338 306 local $hook_args{str_level} = $lname;
339  
340 306 my $code_is;
341 {
342 306 ▶ $code_is = run_hooks('create_is_routine' , \%hook_args, 1, $target_type, $target_name) and last; # old name, will be removed
Branch: 1 branch
BranchTrueFalseTotal
$code_is = run_hooks("create_is_routine", \%hook_args, 1, $target_type, $target_name) and last 0 306 306
343 306 $code_is = run_hooks('create_level_checker', \%hook_args, 1, $target_type, $target_name);
344 }
345 306 ▶ die "BUG in configuration: No level_checker routine is produced for routine name $rname" unless $code_is;
Branch: 1 branch
BranchTrueFalseTotal
unless $code_is 0 306 306
346  
347 306 push @routines, [$code_is, $rname, $lnum, $type, $per_target_conf];
348 }
349 }
350  
351 {
352 51 local $hook_args{routines} = \@routines;
353 51 local $hook_args{filters} = \%filters;
354 51 local $hook_args{formatters} = \%formatters;
355 51 local $hook_args{layouter} = $layouter;
356 51 run_hooks('before_install_routines', \%hook_args, 0,
357 $target_type, $target_name);
358 }
359  
360 51 install_routines($target_type, $target_name, \@routines, 1);
361  
362 {
363 51 local $hook_args{routines} = \@routines;
364 51 run_hooks('after_install_routines', \%hook_args, 0,
365 $target_type, $target_name);
366 }
367 }
368  
369 11 1;
370 # ABSTRACT: The bulk of the implementation of Log::ger
371  
372 __END__
↑ Summary ger/Util.pm »