Log.pm

filter: Statementstmt 66.2% 707 / 1067 Branchbran 32.8% 175 / 532 Conditioncond 23.0% 69 / 299 MC/DCmcdc 2.4% 4 / 167 Subroutinesub 87.5% 120 / 137 Podpod 41.3% 12 / 29 totaltotal 48.7% 1087 / 2231 CC 374 SCAR 60.4
CC
374
Cov
50%
dump
1892.0
write
1094.0
packages
552.0
CRAP 420.2
↑ Summary Log/Filter.pm »
1 package Easy::Log;
2 # -t STDOUT -t STDERR ???
3 1 my $prefix_dev_backstack = 2;
4 1 ▶use Easy::Log::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 my $filter_file;
6 1 our $this_package;
7 1 ▶BEGIN {
Subroutine BEGIN: called CC=6 SCAR=22.9
8 # this little but of cruft really sucks, but neither 'require' nor 'do' are bahaving as I would expect(akin to a c #include)
9 #require '/home/lengthe/cvs/adg/util/general/Log/Filter.pm';
10 #require Easy::Log::Filter;
11 #do Easy::Log::Filter;
12 1 $filter_file = __PACKAGE__ eq 'Easy::Log' ? __FILE__ : ( $INC{'Easy/Log.pm'} or die "Couldn't find location of Easy/Log.pm package" );
13 1 $filter_file =~ s|Log.pm|Log/Filter.pm|;
14 1 ▶ print STDERR "filter_file=$filter_file\n" if $ENV{LOG_FILTER_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
15 1 my $eval = 'package ' . __PACKAGE__ . ';';
16 # this is somewhat evil, but I need to do it to get filtering in THIS package, as well as packages that use this package
17 1 ▶ open(FILTER, "<$filter_file") or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open FILTER, "<$filter_file" or die $! 1 0 1
18 1 $eval .= '#' . join("", <FILTER>); #`cat $filter_file`; # the '#' here comments out the first line of the filter package 'package Easy::Log::Filter;'
19 1 close FILTER;
20 1 $eval =~ /(.*)/ms; # for untainting in case taint mode is on
21 1 $eval = $1;
22 1 ▶ print STDERR "EVAL:#########################\n$eval\n########################\n" if $ENV{LOG_FILTER_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
23 0 ▶ eval "{ $eval }";
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine BEGIN: called CC=29 SCAR=49.1
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine pad: called CC=9 SCAR=29.6
Subroutine space: called CC=9 SCAR=29.6
Subroutine space_pad: not called CC=9 SCAR=29.6
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 45 branches
BranchTrueFalseTotal
exists $ENV{'LOG_FILTER_DEBUG'} ? : 1 0 1
exists $ENV{'LOG_FILTER_PACKAGES_DEBUG'} ? : 1 0 1
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
unless (defined $FILTER_REGEX) 1 0 1
if ($ENV{'LOG_FILTER'} =~ /^off$/i) { } 0 1 1
elsif ($ENV{'LOG_FILTER'} =~ /^(on|\d+)$/i) { } 1 0 1
if $ENV{"LOG_FILTER_DEBUG"} 0 0 0
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
if $ENV{"LOG_FILTER_DEBUG"} 0 0 0
if ($piece =~ /^\!/) { } 0 0 0
if $ENV{"LOG_FILTER_DEBUG"} 0 0 0
if $ENV{"LOG_FILTER_DEBUG"} 0 0 0
if (scalar keys %filter) { } 0 0 0
if $ENV{"LOG_FILTER_DEBUG"} 0 0 0
$_ =~ /$not_filter_rx/ ? : 0 0 0
$_ =~ /$not_filter_rx/ ? : 0 0 0
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
unless (defined $FILTER_ALL_REGEX) 1 0 1
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
unless (defined $MATCH_LOG_LEVEL_REGEX) 1 0 1
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
defined $max or $max = 27 4630 0 4630
unless (defined $separator and length $separator > 0) 4630 0 4630
defined $piece ? : 4630 0 4630
$lp < $max ? : 782 3848 4630
$sp eq 'space' ? : 0 4630 4630
$lr < $max ? : 0 4630 4630
$sp eq 'space' ? : 0 4630 4630
defined $max or $max = 27 4630 0 4630
unless (defined $separator and length $separator > 0) 4630 0 4630
defined $piece ? : 4630 0 4630
$lp < $max ? : 0 4630 4630
$sp eq 'space' ? : 4630 0 4630
$lr < $max ? : 0 4630 4630
$sp eq 'space' ? : 4630 0 4630
defined $max or $max = 27 0 0 0
unless (defined $separator and length $separator > 0) 0 0 0
defined $piece ? : 0 0 0
$lp < $max ? : 0 0 0
$sp eq 'space' ? : 0 0 0
$lr < $max ? : 0 0 0
$sp eq 'space' ? : 0 0 0
Condition33%5/15
$ENV{"LOG_PACKAGES_DEBUG"} ||= 0
l!l
01
$ENV{"LOG_FILTER"} ||= "ON"
l!l
10
$ENV{"LOG_INTERNAL_DEBUG"} ||= 0
l!l
01
defined $separator and length $separator > 0
!ll&&!rl&&r
463000
defined $separator and length $separator > 0
!ll&&!rl&&r
463000
defined $separator and length $separator > 0
!ll&&!rl&&r
000
MC/DC0%0/1
$ENV{"LOG_PACKAGES_DEBUG"} ||= 0
$ENV{"LOG_PACKAGES_DEBUG"}
MC/DC0%0/1
$ENV{"LOG_FILTER"} ||= "ON"
$ENV{"LOG_FILTER"}
MC/DC0%0/1
$ENV{"LOG_INTERNAL_DEBUG"} ||= 0
$ENV{"LOG_INTERNAL_DEBUG"}
MC/DC0%0/2
defined $separator and length $separator > 0
defined $separator length $separator > 0
MC/DC0%0/2
defined $separator and length $separator > 0
defined $separator length $separator > 0
MC/DC0%0/2
defined $separator and length $separator > 0
defined $separator length $separator > 0
Truth table50%1/2
A
A= $ENV{"LOG_PACKAGES_DEBUG"}
Aresult
11
00
Truth table50%1/2
A
A= $ENV{"LOG_FILTER"}
Aresult
11
00
Truth table50%1/2
A
A= $ENV{"LOG_INTERNAL_DEBUG"}
Aresult
11
00
Truth table33%1/3
A and B
A= defined $separatorB= length $separator > 0
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= defined $separatorB= length $separator > 0
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $separatorB= length $separator > 0
ABresult
0X0
100
111
24 1 ▶ (print STDERR '$this_package: ', $this_package, '(', __PACKAGE__, ')', "\n") if $ENV{LOG_FILTER_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_FILTER_DEBUG"} 0 1 1
25 1 ▶ $@ and die $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and die $@ 0 1 1
26 #die;
27 }
28  
29 #
30 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use Fcntl qw(:flock);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use Carp qw( cluck confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 ▶if ( $ENV{LOG_USE_CARP} and $ENV{LOG_USE_CARP} eq 'YES' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"LOG_USE_CARP"} and $ENV{"LOG_USE_CARP"} eq "YES") 0 1 1
Condition33%1/3
$ENV{"LOG_USE_CARP"} and $ENV{"LOG_USE_CARP"} eq "YES"
!ll&&!rl&&r
100
MC/DC0%0/2
$ENV{"LOG_USE_CARP"} and $ENV{"LOG_USE_CARP"} eq "YES"
$ENV{"LOG_USE_CARP"} $ENV{"LOG_USE_CARP"} eq "YES"
Truth table33%1/3
A and B
A= $ENV{"LOG_USE_CARP"}B= $ENV{"LOG_USE_CARP"} eq "YES"
ABresult
0X0
100
111
38 # big ugly stack traces when we encounter a 'warn' or a 'die'
39 0 $SIG{__WARN__} = \&cluck;
40 0 $SIG{__DIE__} = \&confess;
41 }
42  
43 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 our ( %EXPORT_TAGS, @ISA, @EXPORT_OK, @EXPORT, $VERSION );
45 1 @ISA = qw( Exporter );
46  
47 1 $VERSION = '0.02_01';
48  
49 %EXPORT_TAGS = (
50 # available constants for log level text names, these will never be filtered nor will warnings about them ever be made
51 # basically, these are for production level logging (as opposed to the 'shorthand' log levels below in "log_level_[not_]filtered"
52 # as such they can still be used to put the program in DEBUG mode (etc), but for more formalized debugging
53 #log_level => [ Easy::Log::Filter->LOG_LEVELS() ],
54 log_level => [ LOG_LEVELS() ],
55 # global logging object
56 log => [ qw( $log log ) ],
57 # convenient log level aliases that WILL BE FILTERED if appropriate (MUST begin with a $ [eg regular SCALAR variable]
58 #log_level_filtered => [ map { "\$$_" } Easy::Log::Filter->DEFAULT_FILTER() ],
59 1 ll_filtered => [ map { "\$$_" } DEFAULT_FILTER() ],
60 # same as above, but without '$', these will not be filtered, but if $ENV{WARN_FILTER} is set, warnings about unfiltered log messages will show up
61 # this is useful for debugging when you may want a particular message to be displayed (simply delete the '$')
62 #log_level_not_filtered => [ Easy::Log::Filter->DEFAULT_FILTER() ],
63 ll_not_filtered => [ DEFAULT_FILTER() ],
64 # these are utility methods for output formatting
65 misc => [ qw(space pad dump _caller $hostname ) ],
66 );
67  
68 1 $EXPORT_TAGS{all} = [ map {@{$_}} values %EXPORT_TAGS ];
69 1 $EXPORT_TAGS{initialize} = [ @{$EXPORT_TAGS{log_level}} ];
70 1 $EXPORT_TAGS{basic} = [ map { @{$EXPORT_TAGS{$_}} } qw( log_level log ll_filtered ll_not_filtered) ];
71 1 @EXPORT_OK = @{$EXPORT_TAGS{'all'}};
72 1 @EXPORT = ();
73  
74 1 ▶use constant MESSAGE => 'MESSAGE'; # this will send an email to the appointed person
Subroutine BEGIN: called CC=1 SCAR=0.0
75 1 ▶use constant DEFAULT => 'DEFAULT';
Subroutine BEGIN: called CC=1 SCAR=0.0
76 1 ▶use constant LOUD => 'LOUD';
Subroutine BEGIN: called CC=1 SCAR=0.0
77 1 ▶use constant CLEAN => 'CLEAN';
Subroutine BEGIN: called CC=1 SCAR=0.0
78 1 ▶use constant EMERG => 'EMERG';
Subroutine BEGIN: called CC=1 SCAR=0.0
79 1 ▶use constant ALERT => 'ALERT';
Subroutine BEGIN: called CC=1 SCAR=0.0
80 1 ▶use constant QUIT => 'QUIT';
Subroutine BEGIN: called CC=1 SCAR=0.0
81 1 ▶use constant EXIT => 'QUIT'; # synonym for QUIT
Subroutine BEGIN: called CC=1 SCAR=0.0
82 1 ▶use constant CRIT => 'CRIT';
Subroutine BEGIN: called CC=1 SCAR=0.0
83 1 ▶use constant FATAL => 'FATAL'; # synonym for CRIT
Subroutine BEGIN: called CC=1 SCAR=0.0
84 1 ▶use constant FAIL => 'FAIL'; # synonym for CRIT
Subroutine BEGIN: called CC=1 SCAR=0.0
85 1 ▶use constant ERROR => 'ERROR';
Subroutine BEGIN: called CC=1 SCAR=0.0
86 1 ▶use constant WARN => 'WARN';
Subroutine BEGIN: called CC=1 SCAR=0.0
87 1 ▶use constant NOTICE => 'NOTICE';
Subroutine BEGIN: called CC=1 SCAR=0.0
88 1 ▶use constant INFO => 'INFO';
Subroutine BEGIN: called CC=1 SCAR=0.0
89 1 ▶use constant DEBUG99 => 'DEBUG99';
Subroutine BEGIN: called CC=1 SCAR=0.0
90 1 ▶use constant DEBUG9 => 'DEBUG9';
Subroutine BEGIN: called CC=1 SCAR=0.0
91 1 ▶use constant DEBUG8 => 'DEBUG8';
Subroutine BEGIN: called CC=1 SCAR=0.0
92 1 ▶use constant DEBUG7 => 'DEBUG7';
Subroutine BEGIN: called CC=1 SCAR=0.0
93 1 ▶use constant DEBUG6 => 'DEBUG6';
Subroutine BEGIN: called CC=1 SCAR=0.0
94 1 ▶use constant DEBUG5 => 'DEBUG5';
Subroutine BEGIN: called CC=1 SCAR=0.0
95 1 ▶use constant DEBUG4 => 'DEBUG4';
Subroutine BEGIN: called CC=1 SCAR=0.0
96 1 ▶use constant DEBUG3 => 'DEBUG3';
Subroutine BEGIN: called CC=1 SCAR=0.0
97 1 ▶use constant DEBUG2 => 'DEBUG2';
Subroutine BEGIN: called CC=1 SCAR=0.0
98 1 ▶use constant DEBUG1 => 'DEBUG1';
Subroutine BEGIN: called CC=1 SCAR=0.0
99 1 ▶use constant DEBUG0 => 'DEBUG0';
Subroutine BEGIN: called CC=1 SCAR=0.0
100 1 ▶use constant DEBUG => 'DEBUG';
Subroutine BEGIN: called CC=1 SCAR=0.0
101 1 ▶use constant TRACE => 'TRACE';
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use constant SPEW => 'SPEW';
Subroutine BEGIN: called CC=1 SCAR=0.0
103  
104 1 ▶use constant D_MESSAGE => 'D_MESSAGE'; # this will send an email to the appointed person
Subroutine BEGIN: called CC=1 SCAR=0.0
105 1 ▶use constant D_DEFAULT => 'D_DEFAULT';
Subroutine BEGIN: called CC=1 SCAR=0.0
106 1 ▶use constant D_LOUD => 'D_LOUD';
Subroutine BEGIN: called CC=1 SCAR=0.0
107 1 ▶use constant D_CLEAN => 'D_CLEAN';
Subroutine BEGIN: called CC=1 SCAR=0.0
108 1 ▶use constant D_EMERG => 'D_EMERG';
Subroutine BEGIN: called CC=1 SCAR=0.0
109 1 ▶use constant D_ALERT => 'D_ALERT';
Subroutine BEGIN: called CC=1 SCAR=0.0
110 1 ▶use constant D_CRIT => 'D_CRIT';
Subroutine BEGIN: called CC=1 SCAR=0.0
111 1 ▶use constant D_FATAL => 'D_FATAL';
Subroutine BEGIN: called CC=1 SCAR=0.0
112 1 ▶use constant D_FAIL => 'D_FAIL';
Subroutine BEGIN: called CC=1 SCAR=0.0
113 1 ▶use constant D_QUIT => 'D_QUIT';
Subroutine BEGIN: called CC=1 SCAR=0.0
114 1 ▶use constant D_EXIT => 'D_EXIT';
Subroutine BEGIN: called CC=1 SCAR=0.0
115 1 ▶use constant D_ERROR => 'D_ERROR';
Subroutine BEGIN: called CC=1 SCAR=0.0
116 1 ▶use constant D_WARN => 'D_WARN';
Subroutine BEGIN: called CC=1 SCAR=0.0
117 1 ▶use constant D_NOTICE => 'D_NOTICE';
Subroutine BEGIN: called CC=1 SCAR=0.0
118 1 ▶use constant D_INFO => 'D_INFO';
Subroutine BEGIN: called CC=1 SCAR=0.0
119 1 ▶use constant D_DEBUG99 => 'D_DEBUG99';
Subroutine BEGIN: called CC=1 SCAR=0.0
120 1 ▶use constant D_DEBUG9 => 'D_DEBUG9';
Subroutine BEGIN: called CC=1 SCAR=0.0
121 1 ▶use constant D_DEBUG8 => 'D_DEBUG8';
Subroutine BEGIN: called CC=1 SCAR=0.0
122 1 ▶use constant D_DEBUG7 => 'D_DEBUG7';
Subroutine BEGIN: called CC=1 SCAR=0.0
123 1 ▶use constant D_DEBUG6 => 'D_DEBUG6';
Subroutine BEGIN: called CC=1 SCAR=0.0
124 1 ▶use constant D_DEBUG5 => 'D_DEBUG5';
Subroutine BEGIN: called CC=1 SCAR=0.0
125 1 ▶use constant D_DEBUG4 => 'D_DEBUG4';
Subroutine BEGIN: called CC=1 SCAR=0.0
126 1 ▶use constant D_DEBUG3 => 'D_DEBUG3';
Subroutine BEGIN: called CC=1 SCAR=0.0
127 1 ▶use constant D_DEBUG2 => 'D_DEBUG2';
Subroutine BEGIN: called CC=1 SCAR=0.0
128 1 ▶use constant D_DEBUG1 => 'D_DEBUG1';
Subroutine BEGIN: called CC=1 SCAR=0.0
129 1 ▶use constant D_DEBUG0 => 'D_DEBUG0';
Subroutine BEGIN: called CC=1 SCAR=0.0
130 1 ▶use constant D_DEBUG => 'D_DEBUG';
Subroutine BEGIN: called CC=1 SCAR=0.0
131 1 ▶use constant D_TRACE => 'D_TRACE';
Subroutine BEGIN: called CC=1 SCAR=0.0
132 1 ▶use constant D_SPEW => 'D_SPEW';
Subroutine BEGIN: called CC=1 SCAR=0.0
133  
134  
135  
136 # the following, when used as log levels in code calling this package with qw(:all)
137 # these may not be worth the clutter
138 # I have also made identically named scalars which if used will cause the log messages to be filtered out
139 # WARNING: without the `$' the log message WILL NOT be filtered out!
140 1 ▶use constant ll => D_DEFAULT;
Subroutine BEGIN: called CC=1 SCAR=0.0
141 1 ▶use constant mll => D_MESSAGE;
Subroutine BEGIN: called CC=1 SCAR=0.0
142 1 ▶use constant lll => D_LOUD;
Subroutine BEGIN: called CC=1 SCAR=0.0
143 1 ▶use constant cll => D_CLEAN;
Subroutine BEGIN: called CC=1 SCAR=0.0
144 1 ▶use constant qll => D_QUIT;
Subroutine BEGIN: called CC=1 SCAR=0.0
145 1 ▶use constant ell => D_ERROR;
Subroutine BEGIN: called CC=1 SCAR=0.0
146 1 ▶use constant all => D_ALERT;
Subroutine BEGIN: called CC=1 SCAR=0.0
147 1 ▶use constant wll => D_WARN;
Subroutine BEGIN: called CC=1 SCAR=0.0
148 1 ▶use constant nll => D_NOTICE;
Subroutine BEGIN: called CC=1 SCAR=0.0
149 1 ▶use constant ill => D_INFO;
Subroutine BEGIN: called CC=1 SCAR=0.0
150 1 ▶use constant dl99 => D_DEBUG99;
Subroutine BEGIN: called CC=1 SCAR=0.0
151 1 ▶use constant dl9 => D_DEBUG9;
Subroutine BEGIN: called CC=1 SCAR=0.0
152 1 ▶use constant dl8 => D_DEBUG8;
Subroutine BEGIN: called CC=1 SCAR=0.0
153 1 ▶use constant dl7 => D_DEBUG7;
Subroutine BEGIN: called CC=1 SCAR=0.0
154 1 ▶use constant dl6 => D_DEBUG6;
Subroutine BEGIN: called CC=1 SCAR=0.0
155 1 ▶use constant dl5 => D_DEBUG5;
Subroutine BEGIN: called CC=1 SCAR=0.0
156 1 ▶use constant dl4 => D_DEBUG4;
Subroutine BEGIN: called CC=1 SCAR=0.0
157 1 ▶use constant dl3 => D_DEBUG3;
Subroutine BEGIN: called CC=1 SCAR=0.0
158 1 ▶use constant dl2 => D_DEBUG2;
Subroutine BEGIN: called CC=1 SCAR=0.0
159 1 ▶use constant dl1 => D_DEBUG1;
Subroutine BEGIN: called CC=1 SCAR=0.0
160 1 ▶use constant dl0 => D_DEBUG0;
Subroutine BEGIN: called CC=1 SCAR=0.0
161 1 ▶use constant dll => D_DEBUG;
Subroutine BEGIN: called CC=1 SCAR=0.0
162 1 ▶use constant tll => D_TRACE;
Subroutine BEGIN: called CC=1 SCAR=0.0
163 1 ▶use constant sll => D_SPEW;
Subroutine BEGIN: called CC=1 SCAR=0.0
164  
165  
166 1 our ( $p_space, $p_pad ) = ( 8, 8 );
167 1 ▶our $STACK_TRACE = $ENV{LOG_STACK_TRACE} || 0;
Condition50%1/2
$ENV{'LOG_STACK_TRACE'} || 0
l!l
01
MC/DC0%0/1
$ENV{'LOG_STACK_TRACE'} || 0
$ENV{'LOG_STACK_TRACE'}
Truth table50%1/2
A
A= $ENV{'LOG_STACK_TRACE'}
Aresult
11
00
168  
169 1 our ( $DUMPER, $log_level, $log, $intlog );
170  
171 # if we have big warngings set to true for any particular log level then we'll issue a perl 'warn'ing
172 10 our %BIG_WARN_DEFAULTS = ( ( map { ("DEBUG$_" => 0); } ( 0 .. 9 ) ),
173 1 ( map { ($_ => 0);} qw( MESSAGE LOUD CLEAN QUIT EXIT EMERG ALERT CRIT FATAL FAIL ERROR WARN NOTICE INFO DEBUG TRACE SPEW ) ),
174 ( qw( WARN 0 ERROR 0 CRIT 1 FATAL 1 FAIL 0 ) )
175 );
176 #our %BIG_WARN_ON = map { print STDERR qq'BIG_WARN_ON_$_ => ', ( defined $ENV{"BIG_WARN_ON_$_"} ? $ENV{"BIG_WARN_ON_$_"} : 'undef' ), "\n"; ( $_ => ( defined $ENV{"BIG_WARN_ON_$_"} ? $ENV{"BIG_WARN_ON_$_"} : ( $BIG_WARN_DEFAULTS{$_} || 0 ) )); } keys %BIG_WARN_DEFAULTS;
177 1 ▶our %BIG_WARN_ON = map { ( $_ => ( defined $ENV{"BIG_WARN_ON_$_"} ? $ENV{"BIG_WARN_ON_$_"} : ( $BIG_WARN_DEFAULTS{$_} || 0 ) )); } keys %BIG_WARN_DEFAULTS;
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{"BIG_WARN_ON_$_"} ? : 3 24 27
Condition50%1/2
$Easy::Log::BIG_WARN_DEFAULTS{$_} or 0
l!l
024
MC/DC0%0/1
$Easy::Log::BIG_WARN_DEFAULTS{$_} or 0
$Easy::Log::BIG_WARN_DEFAULTS{$_}
Truth table50%1/2
A
A= $Easy::Log::BIG_WARN_DEFAULTS{$_}
Aresult
11
00
178 # these were(are?) actually apache constants for logging levels I think anything that gets in that
179 # is preceded with a '_' gets [0] (numerical value) these return the uppercase(?) version of
180 # themselves
181 our %LOG_CODE = ( STDERR => 0x00E0,
182 STDOUT => 0x00E0,
183 CLEAN => 0x00E0,
184 MESSAGE => 0x00E0,
185 LOUD => 0x00E0,
186 CRIT => 0x00E0,
187 FATAL => 0x00E0,
188 FAIL => 0x00E0,
189 QUIT => 0x00E0,
190 EXIT => 0x00E0,# synonym for QUIT
191 EMERG => 0x00E0,
192 ALERT => 0x0080,
193 ERROR => 0x0070,
194 WARN => 0x0060,
195 NOTICE => 0x0050,
196 INFO => 0x0040,
197 DEBUG99 => 0x0040, # this is the same as INFO, but will cause the line number and package to be printed with EVERY log call if LOG_LEVEL is set to anything that matched '.*DEBUG.*'
198 1 (map { ("DEBUG$_" => ( 0x0030 + $_ )); } ( 0 .. 9 )),
199 DEBUG => 0x0030,
200 TRACE => 0x0020,
201 SPEW => 0x0010,
202 DEFAULT => 0x0030,# set equal to DEBUG
203 );
204 # translate between our more expanded selection of logging levels to what apache understands
205 our %APACHE_LEVELS = ( DEFAULT => INFO,
206 TRACE => DEBUG,
207 SPEW => DEBUG,
208 DEBUG => DEBUG,
209 1 (map { ("DEBUG$_" => 'DEBUG'); } ( 0 .. 9, 99 )),
210 INFO => INFO,
211 WARN => WARN,
212 NOTICE => NOTICE,
213 CRIT => CRIT,
214 FATAL => CRIT,
215 FAIL => CRIT,
216 QUIT => CRIT,
217 EXIT => CRIT,
218 ERROR => ERROR,
219 ALERT => ALERT,
220 EMERG => EMERG,
221 LOUD => ERROR,
222 CLEAN => ERROR,
223 );
224  
225 1 our ( $ll, $lll, $qll, $cll, $ell, $all, $wll, $nll, $ill, $dll, $tll, $sll, $mll, $dl0, $dl1, $dl2, $dl3, $dl4, $dl5, $dl6, $dl7, $dl8, $dl9, $dl99 )
226 = ( ll, lll, qll, cll, ell, all, wll, nll, ill, dll, tll, sll, mll, dl0, dl1, dl2, dl3, dl4, dl5, dl6, dl7, dl8, dl9, dl99 );
227 1 our $n;
228 1 our %LEVEL_FHS = map { ($_ => 'STDERR'); } qw(EMERG ALERT CRIT FATAL FAIL ERROR WARN QUIT);
229  
230 #%ALWAYS_LOG is for log levels that should never be dropped, even if the package is blocked from logging
231 1 our %ALWAYS_LOG = qw(
232 CLEAN 1
233 CRIT 1
234 FATAL 1
235 FAIL 1
236 QUIT 1
237 ERROR 1
238 ALERT 1
239 EMERG 1
240 MESSAGE 1
241 STDOUT 1
242 STDERR 1
243 );
244 1 foreach my $log_level ( LOG_LEVELS ) {
245 56 ▶ $ALWAYS_LOG{$log_level} ||= 0;
Condition100%2/2
$Easy::Log::ALWAYS_LOG{$log_level} ||= 0
l!l
947
MC/DC100%1/1
$Easy::Log::ALWAYS_LOG{$log_level} ||= 0
$Easy::Log::ALWAYS_LOG{$log_level}
Truth table100%2/2
A
A= $Easy::Log::ALWAYS_LOG{$log_level}
Aresult
11
00
246 }
247 1 our $default_log_level = 'INFO';
248 1 our $default_indent = 1;
249 1 our $default_pad = 0;
250 1 ▶$log_level = $ENV{LOG_LEVEL} ||= ( [ map {$ENV{$_}?$_:()}(@{$EXPORT_TAGS{log_level}}) ]->[0] || $default_log_level );
Branch: 1 branch
BranchTrueFalseTotal
$ENV{$_} ? : 0 56 56
Condition33%2/6
$ENV{"LOG_LEVEL"} ||= [map({$ENV{$_} ? $_ : ();} @{$Easy::Log::EXPORT_TAGS{"log_level"};})]->[0] || $Easy::Log::default_log_level
l!l&&r!l&&!r
010
[map({$ENV{$_} ? $_ : ();} @{$Easy::Log::EXPORT_TAGS{'log_level'};})]->[0] || $Easy::Log::default_log_level
l!l&&r!l&&!r
010
MC/DC0%0/3
$ENV{"LOG_LEVEL"} ||= [map({$ENV{$_} ? $_ : ();} @{$Easy::Log::EXPORT_TAGS{"log_level"};})]->[0] || $Easy::Log::default_log_level
$ENV{"LOG_LEVEL"} [map({$ENV{$_} ? $_ : ();} @{$Easy::Log::EXPORT_TAGS{'log_level'};})]->[0] $Easy::Log::default_log_level
Truth table0%0/4
A ||= B || C
A= $ENV{"LOG_LEVEL"}B= [map({$ENV{$_} ? $_ : ();} @{$Easy::Log::EXPORT_TAGS{'log_level'};})]->[0]C= $Easy::Log::default_log_level
ABCresult
1XX1
01X1
0011
0000
251 # message terminator (sometimes we DON'T want newlines!)
252  
253 1 our $default_handle_fatals = 1;
254 1 our $default_unbuffer = 1;
255 1 ▶our $default_fh = $ENV{LOG_FILE_DEFAULT} || $ENV{DEFAULT_LOG_FILE} || 'STDOUT';
Condition40%2/5
$ENV{'LOG_FILE_DEFAULT'} || $ENV{'DEFAULT_LOG_FILE'} || 'STDOUT'
l!l
01
$ENV{"LOG_FILE_DEFAULT"} or $ENV{"DEFAULT_LOG_FILE"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$ENV{'LOG_FILE_DEFAULT'} || $ENV{'DEFAULT_LOG_FILE'} || 'STDOUT'
$ENV{"LOG_FILE_DEFAULT"} $ENV{"DEFAULT_LOG_FILE"}
Truth table33%1/3
A or B
A= $ENV{"LOG_FILE_DEFAULT"}B= $ENV{"DEFAULT_LOG_FILE"}
ABresult
1X1
011
000
256 our %init = ( log_file => $ENV{LOG_FILE} || $default_fh ,
257 log_level => $log_level,
258 dump_refs => (exists $ENV{LOG_DUMP_REFS} ) ? $ENV{LOG_DUMP_REFS} : 1 ,
259 handle_fatals => (exists $ENV{LOG_HANDLE_FATALS}) ? $ENV{LOG_HANDLE_FATALS} : $default_handle_fatals,
260 exclusive => $ENV{LOG_EXCLUSIVE} || '',
261 1 ▶ unbuffer => (exists $ENV{LOG_UNBUFFER} ? $ENV{LOG_UNBUFFER} : $default_unbuffer),
Branch: 3 branches
BranchTrueFalseTotal
exists $ENV{'LOG_DUMP_REFS'} ? : 0 1 1
exists $ENV{'LOG_HANDLE_FATALS'} ? : 0 1 1
exists $ENV{'LOG_UNBUFFER'} ? : 0 1 1
Condition40%2/5
$ENV{'LOG_FILE'} || $Easy::Log::default_fh
l!l&&r!l&&!r
010
$ENV{'LOG_EXCLUSIVE'} || ''
l!l
01
MC/DC0%0/2
$ENV{'LOG_FILE'} || $Easy::Log::default_fh
$ENV{'LOG_FILE'} $Easy::Log::default_fh
MC/DC0%0/1
$ENV{'LOG_EXCLUSIVE'} || ''
$ENV{'LOG_EXCLUSIVE'}
Truth table33%1/3
A || B
A= $ENV{'LOG_FILE'}B= $Easy::Log::default_fh
ABresult
1X1
011
000
Truth table50%1/2
A
A= $ENV{'LOG_EXCLUSIVE'}
Aresult
11
00
262 #prefix => \&_prefix_default,
263 );
264  
265 1 our %FHS_NO = (); # store list of filehandles indexed by fileno()
266 1 our %FHS_NA = (); # store list of filehandles indexed by file name
267 1 our %FHN_NO = (); # corresponding list of filenames for our filehandles indexed by fileno()
268 # OK .. I'm not sure, but trying to use STDIN may be totally retarded
269 #@LEVEL_FHS{qw( STDIN STDOUT STDERR )} = ( \*STDIN , \*STDOUT, \*STDERR );
270 1 @FHS_NA{qw( STDIN STDOUT STDERR )} = ( \*STDIN , \*STDOUT, \*STDERR );
271 1 @FHN_NO{(map { fileno($_); } @FHS_NA{qw( STDIN STDOUT STDERR )})} = qw( STDIN STDOUT STDERR );
272 1 @FHS_NO{keys %FHN_NO} = values %FHN_NO;
273 1 ▶foreach my $fh ( @FHS_NA{qw( STDOUT STDERR )} ) { $log->{unbuffer} ? _unbuffer( $fh ) : (); }
Branch: 1 branch
BranchTrueFalseTotal
$Easy::Log::log->{'unbuffer'} ? : 0 2 2
274  
275  
276 1 $log = $this_package->new();
277 1 $intlog = $this_package->new( { prefix => \&_prefix_dev } );
278  
279 1 our $hostname = `hostname`;
280 #print STDERR '$hostname: ', $hostname;
281 1 chomp $hostname;
282 1 $intlog->write($dll, '$hostname: ', $hostname );
283  
284 1 our @userinfo = get_userinfo();
285 1 our $username = $userinfo[0];
286  
287 1 my @pathinfo = (File::Spec->splitpath( File::Spec->rel2abs( $0 )));
288 1 $intlog->write({prefix=>undef},$sll, '@pathinfo: ', \@pathinfo );
289  
290 1 my $path_base = $0;
291 1 my @o = split( m|/|, $path_base );
292 1 $intlog->write($dll, '@o: ', \@o );
293 1 my $max_path_seg = 3;
294 1 my $num_path_seg = scalar @o;
295 #my $path_abbrev = ( $num_path_seg > $max_path_seg ) ? join('/', map {''} ( 1 .. ( $num_path_seg - $max_path_seg ))), '...', @o[$#o - 1 .. $#o ] ) : $path_base;
296 #my $path_abbrev = ( $num_path_seg > $max_path_seg ) ? join('/', (@o[0 .. 2], map {''} ( 4 .. ( $num_path_seg - $max_path_seg ))), '...', @o[$#o - 1 .. $#o ] ) : $path_base;
297 1 ▶my $path_abbrev = ( $num_path_seg > $max_path_seg ) ? join('/', @o[0 .. 2], '...', @o[$#o - 1 .. $#o ] ) : $path_base;
Branch: 1 branch
BranchTrueFalseTotal
$num_path_seg > $max_path_seg ? : 0 1 1
298  
299 #my $xxx = $intlog;
300 #$xxx->write('STDERR', '%ENV{BIG_WARN_ON_XXX}: ', { map { $_ => ( $ENV{"BIG_WARN_ON_$_"} || 0 ) } keys%BIG_WARN_DEFAULTS } );
301 #$xxx->write('STDERR', '%BIG_WARN_DEFAULTS: ', \%BIG_WARN_DEFAULTS );
302 #$xxx->write('STDERR', '%BIG_WARN_ON: ', \%BIG_WARN_ON );
303  
304 # we don't normally want a stack trace on every log call
305 # enable on any particular call with: $intlog->write({st=>1},$lll, ':');
306 # enable on all calls with: $log->stack_trace( 1 );
307  
308  
309 1 *always_log = \*ALWAYS_LOG;
310 1 ▶sub ALWAYS_LOG {
Subroutine ALWAYS_LOG: called CC=2 SCAR=8.4
Pod undocumented
311 1 my $self = shift;
312 1 my $log_level = shift;
313 1 ▶ $log_level or return %ALWAYS_LOG;
Branch: 1 branch
BranchTrueFalseTotal
$log_level or return %Easy::Log::ALWAYS_LOG 0 1 1
314 0 $log_level =~ s/^D_//;
315 0 return $ALWAYS_LOG{$log_level};
316 }
317  
318  
319 #$intlog->write($lll, '%LOG_CODE: ', "\n", map { (space($_->[0]), ' => ', pad( $_->[1]), "\n") } sort { $a->[1] <=> $b->[1]; } map { [ $_ => $LOG_CODE{$_} ]; } keys %LOG_CODE );
320 #$intlog->packages('!' . $this_package); # uncomment this to disable all internal logging
321  
322 1 ▶$ENV{LOG_PACKAGES} ||= '';
Condition50%1/2
$ENV{"LOG_PACKAGES"} ||= ""
l!l
01
MC/DC0%0/1
$ENV{"LOG_PACKAGES"} ||= ""
$ENV{"LOG_PACKAGES"}
Truth table50%1/2
A
A= $ENV{"LOG_PACKAGES"}
Aresult
11
00
323 1 ▶if ( $ENV{LOG_PACKAGES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"LOG_PACKAGES"}) 0 1 1
324 0 $log->packages($ENV{LOG_PACKAGES});
325 0 $intlog->packages($ENV{LOG_PACKAGES});
326 }
327  
328  
329 # the following two sets of exported variables/subs are for development debugging purposes and are
330 # filtered out at compile time, unless $ENV{LOG_FILTER} is appropriately set. I'm thinking that since
331 # these are for development debugging that they should maybe have some different significance when
332 # it comes to descriptive output. Currently all log messages output the &{$log->{prefix}}(). Perhaps
333 # we should use a bitmask to determine whether or not a log should be output and additionally what
334 # kind of prefix it has. This would allow these to mimic the "production" log levels (in value)
335 # while also allowing us to have more descriptive prefix (caller, etc...) when they are used for
336 # development debugging
337  
338 1 *log_code = \*LOG_CODE;
339 1 ▶sub LOG_CODE {
Subroutine LOG_CODE: called CC=2 SCAR=8.4
Pod undocumented
340 1 my $self = shift;
341 1 my $log_level = shift;
342 1 ▶ $log_level or return %LOG_CODE;
Branch: 1 branch
BranchTrueFalseTotal
$log_level or return %Easy::Log::LOG_CODE 0 1 1
343 0 $log_level =~ s/^D_//;
344 0 return $LOG_CODE{$log_level};
345 }
346  
347 0 ▶sub n { exists $_[1] ? $_[0]->{ n } = $_[1] : $_[0]->{ n }; }
Subroutine n: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 0 0 0
348 0 ▶sub log { exists $_[1] ? $_[0]->{ log } = $_[1] : $_[0]->{ log }; }
Subroutine log: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 0 0 0
349 #sub log {
350 # if ( $_[0] and UNIVERSAL::isa( $_[0], __PACKAGE__ ) ) {
351 # return exists $_[1] ? $_[0]->{ log } = $_[1] : $_[0]->{ log };
352 # } else {
353 # return $log;
354 # }
355 #}
356 62 ▶sub log_level { exists $_[1] ? $_[0]->{ log_level } = $_[1] : $_[0]->{ log_level }; }
Subroutine log_level: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 62 0 62
357 6 ▶sub dump_refs { exists $_[1] ? $_[0]->{ dump_refs } = $_[1] : $_[0]->{ dump_refs }; }
Subroutine dump_refs: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 6 0 6
358 7 ▶sub handle_fatals { exists $_[1] ? $_[0]->{ handle_fatals } = $_[1] : $_[0]->{ handle_fatals }; }
Subroutine handle_fatals: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 7 0 7
359 6 ▶sub exclusive { exists $_[1] ? $_[0]->{ exclusive } = $_[1] : $_[0]->{ exclusive }; }
Subroutine exclusive: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 6 0 6
360 0 ▶sub stack_trace { exists $_[1] ? $_[0]->{ stack_trace } = $_[1] : $_[0]->{ stack_trace }; }
Subroutine stack_trace: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 0 0 0
361 0 ▶sub email { exists $_[1] ? $_[0]->{ email } = $_[1] : $_[0]->{ email }; }
Subroutine email: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 0 0 0
362 2 ▶sub prefix { exists $_[1] ? $_[0]->{ prefix } = $_[1] : $_[0]->{ prefix }; }
Subroutine prefix: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 2 0 2
363 0 ▶sub terse { exists $_[1] ? $_[0]->{ terse } = $_[1] : $_[0]->{ terse }; }
Subroutine terse: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 0 0 0
364 6 ▶sub unbuffer { exists $_[1] ? $_[0]->{ unbuffer } = $_[1] : $_[0]->{ unbuffer }; }
Subroutine unbuffer: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[1] ? : 6 0 6
365 1 *autoflush = \&unbuffer;
366 56 ▶sub log_file {
Subroutine log_file: called CC=11 SCAR=25.2
Pod documented
367 # this needs to be able to take a file handle as well as a filename or symbolic filehandle name (eg 'STDOUT')
368 # I was going to set up something here to be able to pass in a whole list of LEVEL => $file pairs, but on second though, just call the method repeatedly
369 56 my $self = shift;
370 56 ▶ my $level = shift || '';
Condition50%1/2
shift() || ''
l!l
560
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
371 #my @caller = _caller();
372 # print STDERR __LINE__, "-" x 80, "\n", @caller, "\n";# if $ENV{LOG_PACKAGES_DEBUG};
373 # print STDERR __LINE__, " LEVEL=$level\n";# if $ENV{LOG_PACKAGES_DEBUG};
374 56 ▶ my $dest = shift || '';
Condition100%2/2
shift() || ''
l!l
488
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
375 # print STDERR __LINE__, " DEST=$dest\n";# if $ENV{LOG_PACKAGES_DEBUG};
376 56 my $key = 'log_file';
377 # print STDERR __LINE__, " KEY=$key\n";# if $ENV{LOG_PACKAGES_DEBUG};
378 56 ▶ my $valid_level = scalar map { $_ eq $level ? 1 : (); } LOG_LEVELS() if $level;
Branch: 2 branches
BranchTrueFalseTotal
if $level 56 0 56
$_ eq $level ? : 48 3088 3136
379 56 ▶ if ( $level and not $valid_level ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($level and not $valid_level) { } 8 48 56
elsif ($level and $valid_level) { } 48 0 48
Condition66%2/3
$level and not $valid_level
!ll&&!rl&&r
0488
MC/DC50%1/2
$level and not $valid_level
$level not $valid_level
Truth table66%2/3
A and not(B)
A= $levelB= not $valid_level
ABresult
0X0
100
111
380 8 ▶ if ( $dest ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dest) { } 0 8 8
381 #houston we have a problem
382 } else {
383 8 $dest = $level;
384 }
385 ▶ } elsif ( $level and $valid_level ) {
Condition33%1/3
$level and $valid_level
!ll&&!rl&&r
0048
MC/DC0%0/2
$level and $valid_level
$level $valid_level
Truth table33%1/3
A and B
A= $levelB= $valid_level
ABresult
0X0
100
111
386 48 $key .= "_$level";
387 }
388
389 56 ▶ if ( $dest ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dest) 56 0 56
390 56 $self->{$key} = $dest;
391 }
392 # print STDERR __LINE__, " VALID_LEVEL=$valid_level\n";# if $ENV{LOG_PACKAGES_DEBUG};
393 # print STDERR __LINE__, " LEVEL=$level\n";# if $ENV{LOG_PACKAGES_DEBUG};
394 # print STDERR __LINE__, " DEST=$dest\n";# if $ENV{LOG_PACKAGES_DEBUG};
395 # print STDERR __LINE__, " KEY=$key\n";# if $ENV{LOG_PACKAGES_DEBUG};
396 # print STDERR __LINE__, " RETURN=$self->{$key}\n";# if $ENV{LOG_PACKAGES_DEBUG};
397 # print STDERR __LINE__, "-" x 80, "\n";# if $ENV{LOG_PACKAGES_DEBUG};
398 56 return $self->{$key};
399 }
400 0 ▶sub log_file_multiplex {
Subroutine log_file_multiplex: not called CC=21 SCAR=61.4
Pod undocumented
401 0 my $self = shift;
402 # I should change this to accept filehandles as well
403 0 ▶ if ( scalar @_ > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ > 2) 0 0 0
404 0 die "
405 Called with too many arguments
406 the several ways this could be called, maximum of 2 arguments allowed
407 0: () ===> with no arguments, return the log_file unadorned with a specific log_level
408 1: <FILE> ===> set the log_file for any LEVEL not otherwise spoken for to the specified FILE (or 'STDERR', 'STDOUT')
409 2: <LEVEL> ===> return the log_file for the LEVEL specified
410 3: [ <FILE1>, <FILE2, ..., <FILEn> ] ===> set the log_file for any LEVEL not otherwise spoken for to be multiplexed across the specified files in list [ FILE1, FILE2, ..., FILEn]
411 4: [ <LEVEL1>, <LEVEL2>, ..., <LEVELn> ] ===> return the log_file for the list of LEVELs specified
412 5: <LEVEL> => <FILE> ===> set the log_file for the LEVEL specified to FILE
413 6: <LEVEL> => [ <FILE1>, <FILE2>, ..., <FILEn> ] ===> set the log_file for the LEVEL specified to multiplex across files in list [ FILE1, FILE2, ..., FILEn]
414 7: [ <LEVEL1>, <LEVEL2> ] => <FILE> ===> set the log_file for the LEVELS specified to the same file FILE
415 8: [ <LEVEL1>, <LEVEL2> ] => [ <FILE1>, <FILE2>, ..., <FILEn> ] ===> set the log_file for the LEVELS specified to multiplex across files in list [ FILE1, FILE2, ..., FILEn]
416 ";
417 }
418 0 my $key = 'log_file';
419 #$key = 'log_file_multiplex';
420
421 0 ▶ my $level = shift || '';
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
422 0 ▶ my $dest = shift || '';
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
423 0 ▶ if ( not $level and not $dest ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($level or $dest) 0 0 0
Condition0%0/3
$level or $dest
l!l&&r!l&&!r
000
MC/DC0%0/2
$level or $dest
$level $dest
Truth table0%0/3
A or B
A= $levelB= $dest
ABresult
1X1
011
000
424 ######
425 0 return $self->{$key};
426 ######
427 ######################################
428 }
429
430 0 my $reflevel;
431 my $refdest;
432 0 ▶ unless ( ref $level eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $level eq 'ARRAY') { } 0 0 0
433 0 $reflevel = 0;
434 0 $level = [ $level ];
435 } else {
436 0 $reflevel = 1;
437 }
438
439 0 ▶ if ( $level and not $dest ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level and not $dest) 0 0 0
Condition0%0/3
$level and not $dest
!ll&&!rl&&r
000
MC/DC0%0/2
$level and not $dest
$level not $dest
Truth table0%0/3
A and not(B)
A= $levelB= not $dest
ABresult
0X0
100
111
440 # check to see if this is specifying just a level, or just a dest
441 0 ▶ my $valid_level = scalar map { $_ eq $level->[0] ? 1 : (); } LOG_LEVELS() if $level->[0];
Branch: 2 branches
BranchTrueFalseTotal
if $level->[0] 0 0 0
$_ eq $level->[0] ? : 0 0 0
442 0 ▶ if ( $valid_level ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($valid_level) { } 0 0 0
443 0 my @return;
444 0 foreach my $l ( @$level ) {
445 0 ▶ my $vl = scalar map { $_ eq $l ? 1 : (); } LOG_LEVELS();
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $l ? : 0 0 0
446 0 ▶ unless ( $vl ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vl) { } 0 0 0
447 0 die "
448 Something is awry with the arguments you passed:
449 " . join(', ', @$level ) . "
450 ";
451 } else {
452 0 push @return, $self->{$key}{$l};
453 }
454 }
455 ######
456 0 ▶ return $reflevel ? \@return : $return[0];
Branch: 1 branch
BranchTrueFalseTotal
$reflevel ? : 0 0 0
457 ######
458 ######################################
459 } else {
460 # if the arg is not a valid log level then it must be a destination file or filehandle
461 0 $refdest = $reflevel;
462 0 $dest = $level;
463 0 undef $level;
464 }
465 }
466
467 0 ▶ unless ( ref $dest eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dest eq 'ARRAY') { } 0 0 0
468 0 $refdest = 0;
469 0 $dest = [ $dest ];
470 } else {
471 0 ▶ $refdest = defined $refdest ? $refdest : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $refdest ? : 0 0 0
472 }
473
474 0 ▶ if ( $dest and not $level ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dest and not $level) 0 0 0
Condition0%0/3
$dest and not $level
!ll&&!rl&&r
000
MC/DC0%0/2
$dest and not $level
$dest not $level
Truth table0%0/3
A and not(B)
A= $destB= not $level
ABresult
0X0
100
111
475 # we got only one argument and it was a destination without the level specified
476 # this means by default we want to multiplex across the files given
477 0 $self->{$key} = $dest;
478 ######
479 0 return $self->{$key};
480 ######
481 ######################################
482 }
483
484 # here we have both level and dest, which should each now be array refs
485 0 foreach my $l ( @$level ) {
486 0 my $k = "${key}_$l";
487 0 my $pd = $self->{$k};
488 # check to see where $pd and $dest do not agree, close all filehandles in$pd which are not also in $dest
489 0 $self->{$k} = $dest;
490 }
491 0 return $self->{$key};
492 }
493  
494 0 ▶sub packages {
Subroutine packages: not called CC=23 SCAR=63.1
Pod undocumented
495 # this sets up lists of DO and DONT log for packages specified at runtime
496 # if any DO log lists are set up then we will log ONLY from packages who appear in the DO list EVEN IF they are also in the DONT list
497 # if any DONT log lists are set up then we will NEVER log from packages in the DONT log list UNLESS they are in the DO log list
498 0 my $self = shift;
499 0 ▶ if ( exists $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_[0]) 0 0 0
500 0 my @new_packages = @_;
501 0 ▶ my $packages = $self->{packages_array} ||= [];
Condition0%0/2
$self->{"packages_array"} ||= []
l!l
00
MC/DC0%0/1
$self->{"packages_array"} ||= []
$self->{"packages_array"}
Truth table0%0/2
A
A= $self->{"packages_array"}
Aresult
11
00
502 0 ▶ my $do_log = $packages->[0] ||= [];
Condition0%0/2
$packages->[0] ||= []
l!l
00
MC/DC0%0/1
$packages->[0] ||= []
$packages->[0]
Truth table0%0/2
A
A= $packages->[0]
Aresult
11
00
503 0 ▶ my $dont_log = $packages->[1] ||= [];
Condition0%0/2
$packages->[1] ||= []
l!l
00
MC/DC0%0/1
$packages->[1] ||= []
$packages->[1]
Truth table0%0/2
A
A= $packages->[1]
Aresult
11
00
504 0 foreach my $package_set ( @new_packages ) {
505 0 my @package_set = split(/\#/, $package_set );
506 0 foreach my $package ( @package_set ) {
507 0 ▶ next unless ($package and $package !~ /^\s+$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $package and not $package =~ /^\s+$/ 0 0 0
Condition0%0/3
$package and not $package =~ /^\s+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$package and not $package =~ /^\s+$/
$package not $package =~ /^\s+$/
Truth table0%0/3
A and not(B)
A= $packageB= not $package =~ /^\s+$/
ABresult
0X0
100
111
508 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", '$package: ' , $package, "\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
509 0 ▶ if ( $package =~ s/^\!// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($package =~ s/^\!//) { } 0 0 0
510 #it's a dont
511 0 ▶ unless( grep { /^$package$/ } @$dont_log ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {/^$package$/;} @$dont_log) 0 0 0
512 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", 'DONT ::: $package: \'' , $package, "'\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
513 0 push @$dont_log, $package;
514 }
515 } else {
516 0 ▶ unless( grep { /^$package$/ } @$do_log ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {/^$package$/;} @$do_log) 0 0 0
517 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", 'DO ::: $package: \'' , $package, "'\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
518 0 push @$do_log, $package;
519 }
520 }
521 }
522 }
523 0 ▶ if ( my $packages = $self->{packages_array} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $packages = $self->{"packages_array"}) 0 0 0
524 0 my $do_log = $packages->[0];
525 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", '$do_log: ' , scalar @$do_log , " :: '", join('|', @$do_log) , "'\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
526 0 my $dont_log = $packages->[1];
527 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", '$dont_log: ', scalar @$dont_log, " :: '", join('|', @$dont_log), "'\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
528 0 ▶ my $packages_rx = $self->{packages} ||= [];
Condition0%0/2
$self->{"packages"} ||= []
l!l
00
MC/DC0%0/1
$self->{"packages"} ||= []
$self->{"packages"}
Truth table0%0/2
A
A= $self->{"packages"}
Aresult
11
00
529 0 ▶ my $do_log_rx = scalar @$do_log ? [ map { qr/$_/; } @$do_log ] : []; #scalar @$do_log ? join('|', @$do_log ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
scalar @$do_log ? : 0 0 0
530 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", '$do_log_rx: ' , scalar @$do_log_rx , " :: '", join('|', @$do_log_rx) , "'\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
531 0 ▶ my $dont_log_rx = scalar @$dont_log ? [ map { qr/$_/; } @$dont_log ] : []; #scalar @$dont_log ? join('|', @$dont_log ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
scalar @$dont_log ? : 0 0 0
532 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", '$dont_log_rx: ', scalar @$dont_log_rx, " :: '", join('|', @$dont_log_rx), "'\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
533 0 $packages_rx->[0] = $do_log_rx;
534 0 $packages_rx->[1] = $dont_log_rx;
535 }
536 }
537 0 return $self->{packages};
538 }
539  
540 0 ▶sub clone {
Subroutine clone: not called CC=3 SCAR=24.8
Pod documented
541 0 my $self = shift;
542 0 my $VAR1 = $self->dump( @_ );
543 0 my $clone = eval $VAR1;
544 0 ▶ $clone->{prefix} = $self->{prefix} if ( UNIVERSAL::isa( $clone, $this_package ) and ref $self->{prefix} eq 'CODE' );
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($clone, $Easy::Log::this_package) and ref $self->{"prefix"} eq "CODE" 0 0 0
Condition0%0/3
UNIVERSAL::isa($clone, $Easy::Log::this_package) and ref $self->{"prefix"} eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::isa($clone, $Easy::Log::this_package) and ref $self->{"prefix"} eq "CODE"
UNIVERSAL::isa($clone, $Easy::Log::this_package) ref $self->{"prefix"} eq "CODE"
Truth table0%0/3
A and B
A= UNIVERSAL::isa($clone, $Easy::Log::this_package)B= ref $self->{"prefix"} eq "CODE"
ABresult
0X0
100
111
545 0 return $clone;
546 }
547  
548  
549  
550 #print STDERR $this_package, " STDERR ", __LINE__, " ::: OH MY! ... ", $log->dump([ \@_ ]);
551 #print STDOUT $this_package, " STDOUT ", __LINE__, " ::: OH MY! ... ", $log->dump([ \@_ ]);
552 6 ▶sub new {
Subroutine new: called CC=3 SCAR=12.3
Pod undocumented
553 #print STDERR _caller();
554 6 my $self = shift;
555 6 ▶ my $class = ref $self || $self || $this_package;
Condition33%2/6
ref $self || $self || $Easy::Log::this_package
l!l&&r!l&&!r
600
ref $self or $self
l!l&&r!l&&!r
060
MC/DC0%0/3
ref $self || $self || $Easy::Log::this_package
ref $self $self $Easy::Log::this_package
Truth table25%1/4
A or B || C
A= ref $selfB= $selfC= $Easy::Log::this_package
ABCresult
1XX1
01X1
0011
0000
556 6 $self = bless {}, $class;
557 6 $self->init( @_ );
558 6 return $self;
559 }
560  
561 6 ▶sub init {
Subroutine init: called CC=6 SCAR=18.2
Pod undocumented
562 6 my $self = shift;
563 6 my $init = shift;
564 6 ▶ if ( defined $init ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $init) { } 4 2 6
565 4 ▶ unless ( ref $init eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $init eq "HASH") 0 4 4
566 0 unshift @_, $init;
567 0 $init = { @_ };
568 }
569 } else {
570 2 $init = {};
571 }
572 6 $init = { %init , %$init }; # override defaults with init args passed in
573 6 ▶ while ( my ( $key, $value ) = each %$init ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$init) 37 6 43
574 37 ▶ next unless $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 0 37 37
575 #$self->{$key} = $value;
576 37 $self->$key( $value );
577 }
578 6 ▶ while ( my ( $level, $fh ) = each %LEVEL_FHS ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Easy::Log::LEVEL_FHS) 48 6 54
579 48 $self->log_file( $level => $fh );
580 }
581 #print STDERR "$self: ", &dump( $self, -d => $self );
582 6 return $self;
583 };
584  
585 0 ▶sub dump {
Subroutine dump: not called CC=43 SCAR=75.5
Pod undocumented
586 0 my $DUMP = '';
587 0 my $self = shift;
588 0 ▶ (print STDERR $this_package, " STDERR ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), Dumper(\@_), "\n") if $ENV{LOG_INTERNAL_DUMP_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DUMP_DEBUG"} 0 0 0
589 0 ▶ my $class = ref $self || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
590 0 my ( $dumps, $names );
591 0 my ( $pure, $deep, $indent, $id, $terse, $pad, $deparse );
592 0 ▶ if ( $_[0] and $_[0] =~ /^-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] =~ /^-/) { } 0 0 0
Condition0%0/3
$_[0] and $_[0] =~ /^-/
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] =~ /^-/
$_[0] $_[0] =~ /^-/
Truth table0%0/3
A and B
A= $_[0]B= $_[0] =~ /^-/
ABresult
0X0
100
111
593 0 my $args = { @_ };
594 0 ▶ $dumps = $args->{-d} || $args->{-dump} || $self;
Condition0%0/6
$args->{'-d'} || $args->{'-dump'} || $self
l!l&&r!l&&!r
000
$args->{"-d"} or $args->{"-dump"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'-d'} || $args->{'-dump'} || $self
$args->{"-d"} $args->{"-dump"} $self
Truth table0%0/4
A or B || C
A= $args->{"-d"}B= $args->{"-dump"}C= $self
ABCresult
1XX1
01X1
0011
0000
595 0 ▶ $names = $args->{-n} || $args->{-names} || undef;
Condition0%0/5
$args->{'-n'} || $args->{'-names'} || undef
l!l
00
$args->{"-n"} or $args->{"-names"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{'-n'} || $args->{'-names'} || undef
$args->{"-n"} $args->{"-names"}
Truth table0%0/3
A or B
A= $args->{"-n"}B= $args->{"-names"}
ABresult
1X1
011
000
596 0 ▶ $dumps = [ $dumps ] unless ( ref $names eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $names eq "ARRAY" 0 0 0
597 0 ▶ $pure = $args->{-pure} || 0 ;
Condition0%0/2
$args->{'-pure'} || 0
l!l
00
MC/DC0%0/1
$args->{'-pure'} || 0
$args->{'-pure'}
Truth table0%0/2
A
A= $args->{'-pure'}
Aresult
11
00
598 0 ▶ $deep = $args->{-deep} || 0 ;
Condition0%0/2
$args->{'-deep'} || 0
l!l
00
MC/DC0%0/1
$args->{'-deep'} || 0
$args->{'-deep'}
Truth table0%0/2
A
A= $args->{'-deep'}
Aresult
11
00
599 0 ▶ $indent = ( defined $args->{-indent} ? $args->{-indent} : $default_indent );
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'-indent'} ? : 0 0 0
600 0 ▶ $id = $args->{-id} || 0;
Condition0%0/2
$args->{'-id'} || 0
l!l
00
MC/DC0%0/1
$args->{'-id'} || 0
$args->{'-id'}
Truth table0%0/2
A
A= $args->{'-id'}
Aresult
11
00
601 0 ▶ $terse = $args->{-terse} || 0 ;
Condition0%0/2
$args->{'-terse'} || 0
l!l
00
MC/DC0%0/1
$args->{'-terse'} || 0
$args->{'-terse'}
Truth table0%0/2
A
A= $args->{'-terse'}
Aresult
11
00
602 0 ▶ $pad = $args->{-p} || $args->{-pad} || ' ' x $default_pad;
Condition0%0/6
$args->{'-p'} || $args->{'-pad'} || ' ' x $Easy::Log::default_pad
l!l&&r!l&&!r
000
$args->{"-p"} or $args->{"-pad"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'-p'} || $args->{'-pad'} || ' ' x $Easy::Log::default_pad
$args->{"-p"} $args->{"-pad"} ' ' x $Easy::Log::default_pad
Truth table0%0/4
A or B || C
A= $args->{"-p"}B= $args->{"-pad"}C= ' ' x $Easy::Log::default_pad
ABCresult
1XX1
01X1
0011
0000
603 0 ▶ $deparse = $args->{-deparse} || 0;
Condition0%0/2
$args->{'-deparse'} || 0
l!l
00
MC/DC0%0/1
$args->{'-deparse'} || 0
$args->{'-deparse'}
Truth table0%0/2
A
A= $args->{'-deparse'}
Aresult
11
00
604 0 ▶ if ( $terse and not defined $indent ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($terse and not defined $indent) 0 0 0
Condition0%0/3
$terse and not defined $indent
!ll&&!rl&&r
000
MC/DC0%0/2
$terse and not defined $indent
$terse not defined $indent
Truth table0%0/3
A and not(B)
A= $terseB= not defined $indent
ABresult
0X0
100
111
605 0 $indent = 0;
606 }
607 } else {
608 0 ▶ $dumps = shift || $self;
Condition0%0/3
shift() || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $self
shift() $self
Truth table0%0/3
A || B
A= shift()B= $self
ABresult
1X1
011
000
609 0 ▶ $names = shift || undef;
Condition0%0/2
shift() || undef
l!l
00
MC/DC0%0/1
shift() || undef
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
610 0 ▶ $pure = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
611 0 ▶ $deep = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
612 0 ▶ $indent = shift || $default_indent;
Condition0%0/3
shift() || $Easy::Log::default_indent
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $Easy::Log::default_indent
shift() $Easy::Log::default_indent
Truth table0%0/3
A || B
A= shift()B= $Easy::Log::default_indent
ABresult
1X1
011
000
613 0 ▶ $id = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
614 0 ▶ $terse = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
615 0 ▶ $pad = shift || ' ' x $default_pad;
Condition0%0/3
shift() || ' ' x $Easy::Log::default_pad
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || ' ' x $Easy::Log::default_pad
shift() ' ' x $Easy::Log::default_pad
Truth table0%0/3
A || B
A= shift()B= ' ' x $Easy::Log::default_pad
ABresult
1X1
011
000
616 0 ▶ $deparse = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
617 }
618 0 ▶ (print STDERR $this_package, " STDERR ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), Dumper([( $pure, $deep, $indent, $id, $terse)]), "\n") if $ENV{LOG_INTERNAL_DUMP_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DUMP_DEBUG"} 0 0 0
619
620 0 ▶ ( defined $dumps ) and ( ref $dumps eq 'ARRAY' ) or ( $dumps = [ $dumps ] );
Branch: 1 branch
BranchTrueFalseTotal
defined $dumps and ref $dumps eq "ARRAY" or $dumps = [$dumps] 0 0 0
Condition0%0/3
defined $dumps and ref $dumps eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $dumps and ref $dumps eq "ARRAY"
defined $dumps ref $dumps eq "ARRAY"
Truth table0%0/3
A and B
A= defined $dumpsB= ref $dumps eq "ARRAY"
ABresult
0X0
100
111
621 0 ▶ ( defined $names ) and ( ref $names eq 'ARRAY' ) or ( $names = [ $names ] );
Branch: 1 branch
BranchTrueFalseTotal
defined $names and ref $names eq "ARRAY" or $names = [$names] 0 0 0
Condition0%0/3
defined $names and ref $names eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $names and ref $names eq "ARRAY"
defined $names ref $names eq "ARRAY"
Truth table0%0/3
A and B
A= defined $namesB= ref $names eq "ARRAY"
ABresult
0X0
100
111
622 0 ▶ if ( $id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id) 0 0 0
623 0 ▶ for( my $i = 0; $i <= $#$dumps; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $dumps->$#*) 0 0 0
624 0 my $d = $dumps->[$i];
625 0 ▶ my $n = ref $d ? $d : \$d;
Branch: 1 branch
BranchTrueFalseTotal
ref $d ? : 0 0 0
626 0 $names->[$i] = $n;
627 }
628 }
629 0 my $dumper = Data::Dumper->new( $dumps , $names );
630 0 ▶ $dumper->Pad ( $pad ) if defined $pad;
Branch: 1 branch
BranchTrueFalseTotal
if defined $pad 0 0 0
631 0 ▶ $dumper->Purity ( $pure ) if defined $pure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $pure 0 0 0
632 0 ▶ $dumper->Deepcopy( $deep ) if defined $deep;
Branch: 1 branch
BranchTrueFalseTotal
if defined $deep 0 0 0
633 0 ▶ $dumper->Terse ( $terse ) if defined $terse;
Branch: 1 branch
BranchTrueFalseTotal
if defined $terse 0 0 0
634 0 ▶ $dumper->Indent ( $indent ) if defined $indent;
Branch: 1 branch
BranchTrueFalseTotal
if defined $indent 0 0 0
635 0 ▶ $dumper->Deparse ( $deparse ) if defined $deparse;
Branch: 1 branch
BranchTrueFalseTotal
if defined $deparse 0 0 0
636 0 $DUMP = $dumper->Dump();
637 0 return $DUMP
638 }
639  
640  
641 #sub _prepare_message {
642 # my $self = shift;
643 # my $level = shift;
644 # my $args = shift;
645 # my @inmsg = @_;
646 # my $dump_refs = exists $args->{dump_refs} ? $args->{dump_refs}
647 # : exists $self->{dump_refs} ? $self->{dump_refs}
648 # : $level eq 'SPEW';
649 # my @outmsg = ();
650 # my $tmp;
651 #
652 # $level = $args->{level} || $level;
653 # my $log_level = $args->{log_level} || $self->{log_level} || $ENV{LOG_LEVEL};
654 # print STDERR __LINE__, " LOG_LEVEL='$log_level', LEVEL='$level', \$args->{prefix}='$args->{prefix}'\n" if ($ENV{LOG_INTERNAL_DEBUG} > 2);
655 # my $prefix = exists $args->{prefix} ? $args->{prefix}
656 # : $log_level =~ /^D_/ ? \&_prefix_dev
657 # : $level =~ /CLEAN/ ? ''
658 # : defined $self->{prefix} ? $self->{prefix}
659 # : $level =~ /^D/ ? \&_prefix_dev
660 # : $log_level =~ /(SPEW)/ ? \&_prefix_dev
661 # #: $level =~ /QUIT/ ? \&_prefix_dev
662 # : $level =~ /CRIT/ ? \&_prefix_dev
663 # : $level =~ /FATAL/ ? \&_prefix_dev
664 # : $level =~ /FAIL/ ? \&_prefix_dev
665 # : \&_prefix_default;
666 # my @prefix;
667 # my @prefix_out;
668 # my $add_dev_prefix;
669 # my $log_file = $args->{log_file} || $self->log_file( $level ) || $self->log_file();
670 # if ( exists $args->{prefix}
671 # and $log_level =~ /^D_/
672 # and $log_file =~ /^(STDOUT|STDERR)$/
673 # ) {
674 # $add_dev_prefix = 1;
675 # }
676 # push @prefix, \&_prefix_dev if $add_dev_prefix;
677 # push @prefix, $prefix if defined $prefix;
678 # # really we should have somethings that checks the %args for ALL of the possible settings
679 # my $st = $STACK_TRACE;
680 # $STACK_TRACE = exists $args->{stack_trace} ? $args->{stack_trace}
681 # : defined $self->{stack_trace} ? $self->{stack_trace}
682 # : $STACK_TRACE;
683 #
684 # my $code_resolve_cnt_max = 10;
685 # foreach my $p ( @prefix ) {
686 # my $code_resolve_cnt = 0;
687 # CORE_PREFIX:
688 # while ( ref $p eq 'CODE' ) {
689 # $p = &$p( $level, $args );
690 # last CODE_PREFIX if ( $code_resolve_cnt++ > $code_resolve_cnt_max );
691 # }
692 # unshift @inmsg, $p;
693 # #unshift @prefix_out, $p;
694 # }
695 # $STACK_TRACE = $st;# restore the previous setting
696 #
697 # # my $prefix_length = [ split("\n", join( '', @prefix_out)) ];
698 # # $prefix_length = $prefix_length->[-1];
699 # # $prefix_length = length $prefix_length;
700 # my ($msg, $d);
701 # INMSG: while ( scalar @inmsg ) {
702 # $tmp = undef;
703 # $msg = shift @inmsg;
704 # defined $msg or $msg = 'undef';#'(UNDEFINED ELEMENT IN LOG MESSAGE ARGUMENTS)';
705 # my $code_resolve_cnt = 0;
706 # CHECK_REF:
707 # if (( my $ref = ref $msg ) and $dump_refs ) {
708 # # this next line of cruft is here so you can pass arguments to ->dump() without having to prepend with a minus sign
709 # my @extra_args = map { $_ =~ /^(terse|deep|pure|id|indent)$/ ? ( "-$_" => $args->{$_} ) : ( $_ => $args->{$_} ) } keys %$args;
710 # (print STDERR $this_package, " STDERR ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), $self->dump(-d=> [\@extra_args], -n =>['extra_args']), "\n") if ( $ENV{LOG_INTERNAL_DEBUG} > 4 );
711 # if ( $ref eq 'CODE' ) {
712 # $d = &$msg();
713 # $msg = $d;
714 # goto CHECK_REF unless ( ref $msg eq 'CODE' and $code_resolve_cnt++ > $code_resolve_cnt_max );
715 # } else {
716 # #$d = $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, @extra_args, -pad => (' ' x ( $prefix_length + length $msg) ));
717 # #$d = $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, @extra_args, -pad => (' ' x ( $prefix_length) ));
718 # #$d =~ s/^\s+//;
719 # #$d = "\n" . $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, @extra_args, -pad => (' ' x $prefix_length ) );
720 # #$d = "\n" . $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, -indent => 1, @extra_args );
721 # $d = "\n" . $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, -indent => 1, @extra_args );
722 # }
723 # $msg = $d;
724 # }
725 # push @outmsg, $msg;
726 # }
727 # if ( $add_dev_prefix
728 # and $outmsg[-1] !~ /\n$/ms
729 # ) {
730 # push @outmsg, "\n";
731 # };
732 # return @outmsg;
733 #}
734  
735 1 *_prefix_default = \&_prefix_prod;
736  
737 926 ▶sub _time {
Subroutine _time: called CC=3 SCAR=11.4
738 926 my @lt = localtime();
739 #( 0, 1, 2, 3, 4, 5, 6, 7, 8)
740 #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
741 926 ▶ join('',$lt[5]+1900, map { length $_ < 2 ? "0$_" : $_; } (($lt[4]+1),($lt[3])) ) . ' ' . join('', map { length $_ < 2 ? "0$_" : $_;} @lt[2,1,0]),
Branch: 2 branches
BranchTrueFalseTotal
length $_ < 2 ? : 0 1852 1852
length $_ < 2 ? : 0 2778 2778
742 }
743  
744 926 ▶sub _prefix_prod {
Subroutine _prefix_prod: called CC=2 SCAR=7.0
745 926 ▶ print STDERR __LINE__, " 'prefix_prod'\n" if ($ENV{LOG_INTERNAL_DEBUG} > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 2 0 926 926
746 926 my $level = shift;
747 926 return '['.join('][',map { space(pad($_, $p_pad), $p_space), }
748 "$username\@$hostname:$$",
749 _time(),
750 uc $level
751 )."] "
752 ;
753 }
754  
755 0 ▶sub _prefix_brief {
Subroutine _prefix_brief: not called CC=2 SCAR=17.9
756 0 ▶ print STDERR __LINE__, " 'prefix_brief'\n" if ($ENV{LOG_INTERNAL_DEBUG} > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 2 0 0 0
757 0 my $level = shift;
758 0 return '['.join('][',map { space(pad($_, $p_pad), $p_space), }
759 "$username\@$hostname:$$",
760 _time(),
761 )."] "
762 ;
763 }
764  
765 926 ▶sub _prefix_dev {
Subroutine _prefix_dev: called CC=4 SCAR=14.0
766 926 ▶ print STDERR __LINE__, " 'prefix_dev_long'\n" if ($ENV{LOG_INTERNAL_DEBUG} > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 2 0 926 926
767 926 my $level = shift;
768 926 my $args = shift;
769 926 ▶ my $backstack = $args->{backstack} || 0;
Condition50%1/2
$args->{'backstack'} || 0
l!l
0926
MC/DC0%0/1
$args->{'backstack'} || 0
$args->{'backstack'}
Truth table50%1/2
A
A= $args->{'backstack'}
Aresult
11
00
770 #"$username\@$hostname:$$:$path_abbrev:$path_base",
771 926 my $return = '--['.join("]\n--[",map { space(pad($_, $p_pad), $p_space), }
772 #__PACKAGE__->_caller($backstack + 3), # we need a 3 here to ignore (skip over) the subroutine calls within the logging module itself
773 # was 3 before we inlined something
774 __PACKAGE__->_caller($backstack + $prefix_dev_backstack), # we need a 2 here to ignore (skip over) the subroutine calls within the logging module itself
775 )."] "
776 . "\n"
777 ;
778 926 $return .= _prefix_prod( $level, $args, @_ );
779 926 ▶ $return .= "\n" if ( $level =~ /CLEAN/ );
Branch: 1 branch
BranchTrueFalseTotal
if $level =~ /CLEAN/ 56 870 926
780 926 return $return;
781 }
782  
783 1 my %level_cache = ();
784 0 ▶sub _check_level {
Subroutine _check_level: not called CC=10 SCAR=47.0
785 0 my $self = shift;
786 0 my $msg = shift;
787 0 my $args = {};
788 0 my $level = shift @$msg;
789 0 ▶ ref $level eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
ref $level eq "HASH" and $args = $level and $level = shift @$msg 0 0 0
Condition0%0/3
ref $level eq "HASH" and $args = $level
!ll&&!rl&&r
000
MC/DC0%0/2
ref $level eq "HASH" and $args = $level
ref $level eq "HASH" $args = $level
Truth table0%0/3
A and B
A= ref $level eq "HASH"B= $args = $level
ABresult
0X0
100
111
790 and ($args=$level)
791 and $level=shift @$msg;
792 0 my $map_level = $level;
793 0 $map_level =~ s/^D_//;
794 #print "LEVEL : '$level'\n";
795 #print "MAP_LEVEL: '$map_level'\n";
796 0 ▶ $args->{log_file} ||= $self->{"log_file_$level"} || $self->{"log_file"};
Condition0%0/6
$args->{"log_file"} ||= $$self{"log_file_$level"} || $self->{"log_file"}
l!l&&r!l&&!r
000
$$self{"log_file_$level"} || $self->{'log_file'}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{"log_file"} ||= $$self{"log_file_$level"} || $self->{"log_file"}
$args->{"log_file"} $$self{"log_file_$level"} $self->{'log_file'}
Truth table0%0/4
A ||= B || C
A= $args->{"log_file"}B= $$self{"log_file_$level"}C= $self->{'log_file'}
ABCresult
1XX1
01X1
0011
0000
797 0 ▶ my $log_level = $args->{log_level} ||= $self->{log_level} || DEFAULT;
Condition0%0/5
$args->{"log_level"} ||= $self->{"log_level"} || "DEFAULT"
l!l&&r!l&&!r
000
$self->{'log_level'} || 'DEFAULT'
l!l
00
MC/DC0%0/2
$args->{"log_level"} ||= $self->{"log_level"} || "DEFAULT"
$args->{"log_level"} $self->{'log_level'}
Truth table0%0/3
A ||= B
A= $args->{"log_level"}B= $self->{'log_level'}
ABresult
1X1
011
000
798 0 my $map_log_level = $log_level;
799 0 $map_log_level =~ s/^D_//;
800 0 my ( $_level, $_log_level ) = @LOG_CODE{$map_level, $map_log_level};
801 0 ▶ print STDERR "\nLEVELS: $log_level:$map_log_level:$_log_level ... $level:$map_level:$_level\n" if $ENV{LOG_LEVEL_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_LEVEL_DEBUG"} 0 0 0
802
803 0 ▶ if ( not defined $_level ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_level) 0 0 0
804 0 $intlog->write({stack_trace => 1 }, ERROR, "Illegal log level '$level' setting it to 'DEFAULT'");
805 0 unshift @$msg, ( $level = 'DEFAULT' );
806 0 ▶ return $self->_check_level( $msg ) unless exists $level_cache{$level};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $level_cache{$level} 0 0 0
807 0 $intlog->write( ERROR, "Illegal log level '$level' trouble setting it to $level");
808 0 return undef;
809 }
810
811 0 my @return = ($level, $_level, $log_level, $_log_level, $args);
812 #_actually_log( $self, -level => LOUD, -FH => \*STDOUT, -message => \@return );
813 0 return @return;
814 }
815  
816 12545 ▶sub write {
Subroutine write: called CC=88 SCAR=70.0
Pod documented
817 #print STDOUT $this_package, " STDOUT ", __LINE__, " ::: OH MY! ... ", $intlog->dump([ \@_ ]);
818
819 # print STDERR $this_package," :: ", join(', ', caller()), "\n";
820 12545 my $self = shift;
821 12545 ▶ ref $self or $self = $log;
Branch: 1 branch
BranchTrueFalseTotal
ref $self or $self = $Easy::Log::log 12545 0 12545
822 12545 ▶ (print STDOUT $this_package, " STDOUT ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), $self->dump(-d=> [$_[0]], -n =>['_args']), "\n") if ( $ENV{LOG_INTERNAL_DEBUG} > 4 );
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 4 0 12545 12545
823 12545 my @msg = @_;
824 #my ($level, $_level, $log_level, $_log_level, $args) = $self->_check_level( \@msg );
825 12545 my ($level, $_level, $log_level, $_log_level, $args);
826 12545 my $use_level;
827 12545 my $map_level;
828 CHECK_LEVEL:
829 #sub _check_level {
830 {
831 #my $self = shift;
832 #my $msg = shift;
833 12545 my $msg = \@msg;
834 #my $args = {};
835 12545 $args = {};
836 #my $level = shift @$msg;
837 12545 $level = shift @$msg;
838 12545 ▶ ref $level eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
ref $level eq "HASH" and $args = $level and $level = shift @$msg 6272 6273 12545
Condition66%2/3
ref $level eq "HASH" and $args = $level
!ll&&!rl&&r
627306272
MC/DC50%1/2
ref $level eq "HASH" and $args = $level
ref $level eq "HASH" $args = $level
Truth table66%2/3
A and B
A= ref $level eq "HASH"B= $args = $level
ABresult
0X0
100
111
839 and ($args=$level)
840 and $level=shift @$msg;
841  
842 12545 ▶ $use_level = $args->{level} || $level;
Condition33%1/3
$args->{'level'} || $level
l!l&&r!l&&!r
0125450
MC/DC0%0/2
$args->{'level'} || $level
$args->{'level'} $level
Truth table33%1/3
A || B
A= $args->{'level'}B= $level
ABresult
1X1
011
000
843 12545 $map_level = $use_level;
844 12545 $map_level =~ s/^D_//;
845 #print "LEVEL : '$level'\n";
846 #print "MAP_LEVEL: '$map_level'\n";
847 12545 ▶ $args->{log_file} ||= $self->{"log_file_$level"} || $self->{"log_file"};
Condition50%3/6
$args->{"log_file"} ||= $$self{"log_file_$level"} || $self->{"log_file"}
l!l&&r!l&&!r
627262730
$$self{"log_file_$level"} || $self->{'log_file'}
l!l&&r!l&&!r
062730
MC/DC0%0/3
$args->{"log_file"} ||= $$self{"log_file_$level"} || $self->{"log_file"}
$args->{"log_file"} $$self{"log_file_$level"} $self->{'log_file'}
Truth table0%0/4
A ||= B || C
A= $args->{"log_file"}B= $$self{"log_file_$level"}C= $self->{'log_file'}
ABCresult
1XX1
01X1
0011
0000
848 12545 ▶ $log_level = $args->{log_level} || $self->{log_level} || $ENV{LOG_LEVEL} || 'DEFAULT';
Condition37%3/8
$args->{'log_level'} || $self->{'log_level'} || $ENV{'LOG_LEVEL'} || 'DEFAULT'
l!l
125450
$args->{"log_level"} or $self->{"log_level"} or $ENV{"LOG_LEVEL"}
l!l&&r!l&&!r
1254500
$args->{"log_level"} or $self->{"log_level"}
l!l&&r!l&&!r
0125450
MC/DC0%0/3
$args->{'log_level'} || $self->{'log_level'} || $ENV{'LOG_LEVEL'} || 'DEFAULT'
$args->{"log_level"} $self->{"log_level"} $ENV{"LOG_LEVEL"}
Truth table25%1/4
A or B or C
A= $args->{"log_level"}B= $self->{"log_level"}C= $ENV{"LOG_LEVEL"}
ABCresult
1XX1
01X1
0011
0000
849 12545 my $map_log_level = $log_level;
850 12545 $map_log_level =~ s/^D_//;
851 #my ( $_level, $_log_level ) = @LOG_CODE{$map_level, $map_log_level};
852 12545 ( $_level, $_log_level ) = @LOG_CODE{$map_level, $map_log_level};
853 12545 ▶ print STDERR "\nLEVELS: $log_level:$map_log_level:$_log_level ... $level:$map_level:$_level\n" if $ENV{LOG_LEVEL_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_LEVEL_DEBUG"} 0 12545 12545
854
855 12545 ▶ if ( not defined $_level ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_level) 0 12545 12545
856 0 $intlog->write({stack_trace => 1 }, ERROR, "Illegal log level '$level' setting it to 'DEFAULT'");
857 0 unshift @$msg, ( $level = 'DEFAULT' );
858 #return $self->_check_level( $msg ) unless exists $level_cache{$level};
859 0 ▶ if ( not exists $level_cache{$level} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $level_cache{$level}) { } 0 0 0
860 0 goto CHECK_LEVEL;
861 #($level, $_level, $log_level, $_log_level, $args) = $self->_check_level( $msg );
862 } else {
863 0 $intlog->write( ERROR, "Illegal log level '$level' trouble setting it to $level");
864 0 return undef;
865 }
866 }
867
868 # my @return = ($level, $_level, $log_level, $_log_level, $args);
869 # #_actually_log( $self, -level => LOUD, -FH => \*STDOUT, -message => \@return );
870 # return @return;
871 }
872 # this needs to be set up to log at any of severa levels which may be set simultaneously
873 # eg log at WARN and TRACE
874 # log levels should be a list
875 # ie @_log_levels rather than $_log_level
876 12545 ▶ my $backstack = $args->{backstack} || 0;
Condition50%1/2
$args->{'backstack'} || 0
l!l
012545
MC/DC0%0/1
$args->{'backstack'} || 0
$args->{'backstack'}
Truth table50%1/2
A
A= $args->{'backstack'}
Aresult
11
00
877 12545 my $return = \@msg;
878 12545 my $status = 1;
879 12545 ▶ (print STDERR 'XXXXXX ', $this_package, " STDERR ", __LINE__, " ::: OH MY! status=$status ... \$ALWAYS_LOG{$map_level}: '", $ALWAYS_LOG{$map_level}, "' :: ", __PACKAGE__->_caller(), $self->dump(-d=> [$args], -n =>['args']), "\n") if ( $ENV{LOG_INTERNAL_DEBUG} > 4 );
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 4 0 12545 12545
880 12545 ▶ if( not $ALWAYS_LOG{$map_level} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Easy::Log::ALWAYS_LOG{$map_level}) 8400 4145 12545
881 8400 ▶ if ( my $e = $self->{exclusive} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $self->{'exclusive'}) { } 0 8400 8400
882 0 ▶ $level =~ /$e/
Branch: 1 branch
BranchTrueFalseTotal
$level =~ /$e/ or $status = 0 0 0 0
883 or $status = 0;# or return join( '', @$return );
884 } else {
885 8400 ▶ $_level >= $_log_level
Branch: 1 branch
BranchTrueFalseTotal
$_level >= $_log_level or $status = 0 844 7556 8400
886 or $status = 0;
887 #or return join( '', map { defined $_ ? $_ : 'undef' } @$return );
888 }
889 }
890 12545 ▶ (print STDERR 'XXXXXX ', $this_package, " STDERR ", __LINE__, " ::: OH MY! status=$status ... \$ALWAYS_LOG{$map_level}: '", $ALWAYS_LOG{$map_level}, "' :: ", __PACKAGE__->_caller(), $self->dump(-d=> [$args], -n =>['args']), "\n") if ( $ENV{LOG_INTERNAL_DEBUG} > 4 );
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 4 0 12545 12545
891 12545 ▶ if ( #not $ALWAYS_LOG{$map_level} and
Branch: 1 branch
BranchTrueFalseTotal
if ($status and my $packages = $self->{"packages"}) 0 12545 12545
Condition66%2/3
$status and my $packages = $self->{"packages"}
!ll&&!rl&&r
755649890
MC/DC0%0/2
$status and my $packages = $self->{"packages"}
$status my $packages = $self->{"packages"}
Truth table66%2/3
A and B
A= $statusB= my $packages = $self->{"packages"}
ABresult
0X0
100
111
892 $status
893 and my $packages = $self->{packages}
894 ) {
895 0 my $do_match;
896 my $dont_match;
897 0 my $do_log_rx = $packages->[0];
898 0 my $dont_log_rx = $packages->[1];
899  
900 0 my $log_called_package = _log_called_package(1)->[0];
901 #print STDERR __PACKAGE__, ":", __LINE__, ": ", "LOG CALLED PACKAGE: '$log_called_package'\n";
902 0 ▶ if ( scalar @$do_log_rx ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$do_log_rx) 0 0 0
903 0 foreach my $do_rx ( @$do_log_rx ) {
904 0 ▶ if ( $log_called_package =~ /^($do_rx)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($log_called_package =~ /^($do_rx)$/) 0 0 0
905 #print STDERR "DO LOG: $do_log_rx\n";
906 #$do_match = ( $do_match and length $do_match > length $do_rx ) ? $do_match : $do_rx;
907 0 $do_match = $do_rx;
908 }
909 }
910 0 ▶ $do_match or $status = 0;
Branch: 1 branch
BranchTrueFalseTotal
$do_match or $status = 0 0 0 0
911 }
912
913 0 ▶ if ( $status and scalar @$dont_log_rx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status and scalar @$dont_log_rx) 0 0 0
Condition0%0/2
$status and scalar @$dont_log_rx
!ll
00
MC/DC0%0/1
$status and scalar @$dont_log_rx
$status
Truth table0%0/2
A
A= $status
Aresult
00
11
914 0 foreach my $dont_rx ( @$dont_log_rx ) {
915 0 ▶ if ( $status
Branch: 1 branch
BranchTrueFalseTotal
if ($status and $log_called_package =~ /^($dont_rx)$/) 0 0 0
Condition0%0/3
$status and $log_called_package =~ /^($dont_rx)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$status and $log_called_package =~ /^($dont_rx)$/
$status $log_called_package =~ /^($dont_rx)$/
Truth table0%0/3
A and B
A= $statusB= $log_called_package =~ /^($dont_rx)$/
ABresult
0X0
100
111
916 #and not $do_match
917 #and ( not $do_match or ( $dont_log_rx =~ /$do_log_rx/ ))
918 and $log_called_package =~ /^($dont_rx)$/
919 ) {
920 #$dont_match = ( $dont_match and length $dont_match > length $dont_rx ) ? $dont_match : $dont_rx;
921 0 $dont_match = $dont_rx;
922 0 $status = 0;
923 }
924 }
925 }
926
927 0 ▶ if ( $do_match and $dont_match ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($do_match and $dont_match) 0 0 0
Condition0%0/3
$do_match and $dont_match
!ll&&!rl&&r
000
MC/DC0%0/2
$do_match and $dont_match
$do_match $dont_match
Truth table0%0/3
A and B
A= $do_matchB= $dont_match
ABresult
0X0
100
111
928 # if it matches on both DO and DONT, what are we supposed to do? Here we simply say that the match with the lengthiest regex wins
929 0 ▶ $status = ( length $do_match > length $dont_match ) ? 1 : 0 ;
Branch: 1 branch
BranchTrueFalseTotal
length $do_match > length $dont_match ? : 0 0 0
930 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", "DO status=$status ($do_match): $do_log_rx\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
931 0 ▶ print STDERR __PACKAGE__, ":", __LINE__, ": ", "DONT status=$status ($dont_match): $dont_log_rx\n" if $ENV{LOG_PACKAGES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_PACKAGES_DEBUG"} 0 0 0
932 }
933 }
934
935 12545 ▶ print STDERR __LINE__, " LOG_LEVEL='$log_level', LEVEL='$level', MAP_LEVEL='$map_level', \$args->{prefix}='$args->{prefix}'\n" if ($ENV{LOG_INTERNAL_DEBUG} > 2);
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 2 0 12545 12545
936 12545 ▶ if ( $status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status) 4989 7556 12545
937 #warn "STATUS: $status ::: $level:$_level ... $log_level:$_log_level";
938 # this is an effort at in-lining some subroutines
939 #@msg = $self->_prepare_message( $level, $args, @msg );
940 #sub _prepare_message {
941 {
942 # my $self = shift;
943 # my $level = shift;
944 # my $args = shift;
945 # my @inmsg = @_;
946 4989 my @inmsg = @msg;
947 my $dump_refs = exists $args->{dump_refs} ? $args->{dump_refs}
948 : exists $self->{dump_refs} ? $self->{dump_refs}
949 4989 ▶ : $level eq 'SPEW';
Branch: 2 branches
BranchTrueFalseTotal
exists $args->{'dump_refs'} ? : 0 4989 4989
exists $self->{'dump_refs'} ? : 4989 0 4989
950 4989 my @outmsg = ();
951 4989 my $tmp;
952
953 my $prefix = exists $args->{prefix} ? $args->{prefix}
954 : $log_level =~ /^D_/ ? \&_prefix_dev
955 : $use_level =~ /CLEAN/ ? ''
956 : defined $self->{prefix} ? $self->{prefix}
957 4989 ▶ : $use_level =~ /^D/ ? \&_prefix_dev
Branch: 9 branches
BranchTrueFalseTotal
exists $args->{'prefix'} ? : 0 4989 4989
$log_level =~ /^D_/ ? : 926 4063 4989
$use_level =~ /CLEAN/ ? : 3193 870 4063
defined $self->{'prefix'} ? : 870 0 870
$use_level =~ /^D/ ? : 0 0 0
$log_level =~ /SPEW/ ? : 0 0 0
$use_level =~ /CRIT/ ? : 0 0 0
$use_level =~ /FATAL/ ? : 0 0 0
$use_level =~ /FAIL/ ? : 0 0 0
958 : $log_level =~ /SPEW/ ? \&_prefix_dev
959 #: $use_level =~ /QUIT/ ? \&_prefix_dev
960 : $use_level =~ /CRIT/ ? \&_prefix_dev
961 : $use_level =~ /FATAL/ ? \&_prefix_dev
962 : $use_level =~ /FAIL/ ? \&_prefix_dev
963 : \&_prefix_default;
964 4989 my @prefix;
965 my @prefix_out;
966 4989 my $add_dev_prefix;
967 4989 ▶ my $log_file = $args->{log_file} || $self->log_file( $level ) || $self->log_file();
Condition33%2/6
$args->{'log_file'} || $self->log_file($level) || $self->log_file
l!l&&r!l&&!r
498900
$args->{"log_file"} or $self->log_file($level)
l!l&&r!l&&!r
498900
MC/DC0%0/3
$args->{'log_file'} || $self->log_file($level) || $self->log_file
$args->{"log_file"} $self->log_file($level) $self->log_file
Truth table25%1/4
A or B || C
A= $args->{"log_file"}B= $self->log_file($level)C= $self->log_file
ABCresult
1XX1
01X1
0011
0000
968 4989 ▶ if ( exists $args->{prefix}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"prefix"} and $log_level =~ /^D_/ and $log_file =~ /^(STDOUT|STDERR)$/) 0 4989 4989
Condition33%2/6
exists $args->{"prefix"} and $log_level =~ /^D_/ and $log_file =~ /^(STDOUT|STDERR)$/
!ll&&!rl&&r
498900
exists $args->{"prefix"} and $log_level =~ /^D_/
!ll&&!rl&&r
498900
MC/DC0%0/3
exists $args->{"prefix"} and $log_level =~ /^D_/ and $log_file =~ /^(STDOUT|STDERR)$/
exists $args->{"prefix"} $log_level =~ /^D_/ $log_file =~ /^(STDOUT|STDERR)$/
Truth table25%1/4
A and B and C
A= exists $args->{"prefix"}B= $log_level =~ /^D_/C= $log_file =~ /^(STDOUT|STDERR)$/
ABCresult
0XX0
10X0
1100
1111
969 and $log_level =~ /^D_/
970 and $log_file =~ /^(STDOUT|STDERR)$/
971 ) {
972 0 $add_dev_prefix = 1;
973 }
974 4989 ▶ push @prefix, \&_prefix_dev if $add_dev_prefix;
Branch: 1 branch
BranchTrueFalseTotal
if $add_dev_prefix 0 4989 4989
975 4989 ▶ push @prefix, $prefix if defined $prefix;
Branch: 1 branch
BranchTrueFalseTotal
if defined $prefix 4989 0 4989
976 4989 my $code_resolve_cnt = 0;
977 4989 my $code_resolve_cnt_max = 10;
978 # really we should have somethings that checks the %args for ALL of the possible settings
979 4989 my $st = $STACK_TRACE;
980 $STACK_TRACE = exists $args->{stack_trace} ? $args->{stack_trace}
981 : defined $self->{stack_trace} ? $self->{stack_trace}
982 4989 ▶ : $STACK_TRACE;
Branch: 2 branches
BranchTrueFalseTotal
exists $args->{'stack_trace'} ? : 0 4989 4989
defined $self->{'stack_trace'} ? : 0 4989 4989
983
984 4989 foreach my $p ( @prefix ) {
985 CODE_PREFIX:
986 4989 ▶ while ( ref $p eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p eq "CODE") 926 4989 5915
987 926 $p = &$p( $level, $args );
988 926 ▶ last CODE_PREFIX if ( $code_resolve_cnt++ > $code_resolve_cnt_max );
Branch: 1 branch
BranchTrueFalseTotal
if $code_resolve_cnt++ > $code_resolve_cnt_max 0 926 926
989 }
990 4989 unshift @inmsg, $p;
991 #unshift @prefix_out, $p;
992 }
993 4989 $STACK_TRACE = $st;# restore the previous setting
994  
995 # my $prefix_length = [ split("\n", join( '', @prefix_out)) ];
996 # $prefix_length = $prefix_length->[-1];
997 # $prefix_length = length $prefix_length;
998 4989 my ($msg, $d);
999 4989 ▶ INMSG: while ( scalar @inmsg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @inmsg) 14966 4989 19955
1000 14966 $tmp = undef;
1001 14966 $msg = shift @inmsg;
1002 14966 ▶ defined $msg or $msg = 'undef';#'(UNDEFINED ELEMENT IN LOG MESSAGE ARGUMENTS)';
Branch: 1 branch
BranchTrueFalseTotal
defined $msg or $msg = "undef" 14966 0 14966
1003 14966 my $code_resolve_cnt = 0;
1004 CHECK_REF:
1005 14966 ▶ if (( my $ref = ref $msg ) and $dump_refs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ref = ref $msg and $dump_refs) 0 14966 14966
Condition33%1/3
my $ref = ref $msg and $dump_refs
!ll&&!rl&&r
1496600
MC/DC0%0/2
my $ref = ref $msg and $dump_refs
my $ref = ref $msg $dump_refs
Truth table33%1/3
A and B
A= my $ref = ref $msgB= $dump_refs
ABresult
0X0
100
111
1006 # this next line of cruft is here so you can pass arguments to ->dump() without having to prepend with a minus sign
1007 0 ▶ my @extra_args = map { $_ =~ /^(terse|deep|pure|id|indent|deparse)$/ ? ( "-$_" => $args->{$_} ) : ( $_ => $args->{$_} ) } keys %$args;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /^(terse|deep|pure|id|indent|deparse)$/ ? : 0 0 0
1008 0 ▶ (print STDERR $this_package, " STDERR ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), $self->dump(-d=> [\@extra_args], -n =>['extra_args']), "\n") if ( $ENV{LOG_INTERNAL_DEBUG} > 4 );
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 4 0 0 0
1009 0 ▶ if ( $ref eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq 'CODE') { } 0 0 0
1010 0 $d = &$msg();
1011 0 $msg = $d;
1012 0 ▶ goto CHECK_REF unless ( ref $msg eq 'CODE' and $code_resolve_cnt++ > $code_resolve_cnt_max );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $msg eq "CODE" and $code_resolve_cnt++ > $code_resolve_cnt_max 0 0 0
Condition0%0/3
ref $msg eq "CODE" and $code_resolve_cnt++ > $code_resolve_cnt_max
!ll&&!rl&&r
000
MC/DC0%0/2
ref $msg eq "CODE" and $code_resolve_cnt++ > $code_resolve_cnt_max
ref $msg eq "CODE" $code_resolve_cnt++ > $code_resolve_cnt_max
Truth table0%0/3
A and B
A= ref $msg eq "CODE"B= $code_resolve_cnt++ > $code_resolve_cnt_max
ABresult
0X0
100
111
1013 } else {
1014 #$d = $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, @extra_args, -pad => (' ' x ( $prefix_length + length $msg) ));
1015 #$d = $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, @extra_args, -pad => (' ' x ( $prefix_length) ));
1016 #$d =~ s/^\s+//;
1017 #$d = "\n" . $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, @extra_args, -pad => (' ' x $prefix_length ) );
1018 #$d = "\n" . $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, -indent => 1, @extra_args );
1019 0 $d = "\n" . $self->dump(-d=>[$msg],-n=>["$msg"], -deep => 0, -xxindent => 1, -deparse => 1, @extra_args );
1020 }
1021 0 $msg = $d;
1022 }
1023 14966 push @outmsg, $msg;
1024 }
1025 4989 ▶ if ( $add_dev_prefix
Branch: 1 branch
BranchTrueFalseTotal
if ($add_dev_prefix and not $outmsg[-1] =~ /\n$/ms and not defined $args->{"n"}) 0 4989 4989
Condition33%2/6
$add_dev_prefix and not $outmsg[-1] =~ /\n$/ms and not defined $args->{"n"}
!ll&&!rl&&r
498900
$add_dev_prefix and not $outmsg[-1] =~ /\n$/ms
!ll&&!rl&&r
498900
MC/DC0%0/3
$add_dev_prefix and not $outmsg[-1] =~ /\n$/ms and not defined $args->{"n"}
$add_dev_prefix not $outmsg[-1] =~ /\n$/ms not defined $args->{"n"}
Truth table25%1/4
A and not(B) and not(C)
A= $add_dev_prefixB= not $outmsg[-1] =~ /\n$/msC= not defined $args->{"n"}
ABCresult
0XX0
10X0
1100
1111
1026 and $outmsg[-1] !~ /\n$/ms
1027 and not defined $args->{n}
1028 ) {
1029 0 push @outmsg, "\n";
1030 };
1031 #return @outmsg;
1032 4989 @msg = @outmsg;
1033 }
1034  
1035 4989 ▶ $n = exists $args->{n} ? $args->{n} : ($self->{n} || "\n");
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{'n'} ? : 3136 1853 4989
Condition50%1/2
$self->{"n"} or "\n"
l!l
01853
MC/DC0%0/1
$self->{"n"} or "\n"
$self->{"n"}
Truth table50%1/2
A
A= $self->{"n"}
Aresult
11
00
1036 4989 ▶ (print STDERR $this_package, " STDERR ", __LINE__, " ::: OH MY! ... \$ALWAYS_LOG{$use_level}: '", $ALWAYS_LOG{$use_level}, "' :: ", __PACKAGE__->_caller(), $self->dump(-d=> [$args], -n =>['args']), "\n") if ( $ENV{LOG_INTERNAL_DEBUG} > 4 );
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_INTERNAL_DEBUG"} > 4 0 4989 4989
1037 4989 ▶ unless ( $args->{dont_actually_log} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args->{"dont_actually_log"}) 4989 0 4989
1038 #$return = $self->_actually_log( %$args, -level => $use_level, -message => $return );
1039 4989 %$args = ( %$args, -level => $level, -message => $return );
1040 #sub _actually_log {
1041 {
1042
1043 #print STDERR $this_package, " ", __LINE__, " ::: OH MY! ... ", $_[0]->dump([ \@_ ]);
1044 #my $self = shift;
1045 #(warn $this_package, " STDOUT ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), $self->dump(-d=> [\@_], -n =>['_']), "\n") if $ENV{LOG_INTERNAL_DEBUG};
1046 #my $args = { @_ };
1047 4989 ▶ $args->{-terse} ||= $self->{terse};
Condition33%1/3
$args->{"-terse"} ||= $self->{"terse"}
l!l&&r!l&&!r
004989
MC/DC0%0/2
$args->{"-terse"} ||= $self->{"terse"}
$args->{"-terse"} $self->{"terse"}
Truth table33%1/3
A ||= B
A= $args->{"-terse"}B= $self->{"terse"}
ABresult
1X1
011
000
1048 4989 ▶ $args->{-level} ||= INFO;
Condition50%1/2
$args->{"-level"} ||= "INFO"
l!l
49890
MC/DC0%0/1
$args->{"-level"} ||= "INFO"
$args->{"-level"}
Truth table50%1/2
A
A= $args->{"-level"}
Aresult
11
00
1049 4989 ▶ $args->{-message} ||= ' - -- NO MESSAGE -- - ';
Condition50%1/2
$args->{"-message"} ||= " - -- NO MESSAGE -- - "
l!l
49890
MC/DC0%0/1
$args->{"-message"} ||= " - -- NO MESSAGE -- - "
$args->{"-message"}
Truth table50%1/2
A
A= $args->{"-message"}
Aresult
11
00
1050 4989 my $fh = $self->fh( %$args );
1051 4989 ▶ if ( not $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $fh) { } 0 4989 4989
1052 0 my $log_file = $self->log_file($args->{-level});
1053  
1054 0 my $error_level = FATAL;
1055 0 ▶ if ( not $log->handle_fatals() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Easy::Log::log->handle_fatals) 0 0 0
1056 0 $error_level = ERROR;
1057 }
1058 0 $intlog->write($error_level, "No filehandle for `", $args->{-level}, "' on `", $log_file, "'", \%FHS_NA);
1059 0 ▶ exit 1 if $log->handle_fatals();
Branch: 1 branch
BranchTrueFalseTotal
if $Easy::Log::log->handle_fatals 0 0 0
1060 #return undef;
1061 0 $return = undef;
1062 }
1063 else {
1064 #print "MESSAGE: $message\n";
1065 #return $self->_WRITE( %$args, -FH => $fh );
1066 4989 $return = $self->_WRITE( -FH => $fh, %$args );
1067 }
1068 };
1069  
1070 4989 ▶ defined $return or $status = undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $return or $status = undef 4989 0 4989
1071 }
1072 # if ( $use_level eq MESSAGE ) {
1073 # if ( my $email = $args->{email} ? $args->{email} : $self->{email} ) {
1074 # # we should send a message to the bloke?
1075 # } else {
1076 # #$intlog->write(ERROR, "No email address specified to send MESSAGE: $return");
1077 # $self->write(ALERT, "No email address specified to send MESSAGE: $return") unless $self->{DEBUG}{NO_ALERT};
1078 # }
1079 # }
1080 4989 $n = undef;
1081 }
1082 12545 ▶ ref $return eq 'ARRAY' and $return = join('', map { defined $_ ? $_ : 'undef' } @$return);
Branch: 2 branches
BranchTrueFalseTotal
ref $return eq "ARRAY" and $return = join("", map({defined $_ ? $_ : "undef";} @$return)) 7556 4989 12545
defined $_ ? : 33928 0 33928
1083 #print STDOUT $this_package, " STDOUT ", __LINE__, " ::: OH MY! ... ", $intlog->dump([ \@_ ]);
1084 12545 ▶ return wantarray ? ( $status, $return ) : $status ;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 6272 6273 12545
1085 }
1086  
1087 0 ▶sub _actually_log {
Subroutine _actually_log: not called CC=6 SCAR=37.4
1088 #print STDERR $this_package, " ", __LINE__, " ::: OH MY! ... ", $_[0]->dump([ \@_ ]);
1089 0 my $self = shift;
1090 #(warn $this_package, " STDOUT ", __LINE__, " ::: OH MY!:: ", __PACKAGE__->_caller(), $self->dump(-d=> [\@_], -n =>['_']), "\n") if $ENV{LOG_INTERNAL_DEBUG};
1091 0 my $args = { @_ };
1092 0 ▶ $args->{-terse} ||= $self->{terse};
Condition0%0/3
$args->{"-terse"} ||= $self->{"terse"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"-terse"} ||= $self->{"terse"}
$args->{"-terse"} $self->{"terse"}
Truth table0%0/3
A ||= B
A= $args->{"-terse"}B= $self->{"terse"}
ABresult
1X1
011
000
1093 0 ▶ $args->{-level} ||= INFO;
Condition0%0/2
$args->{"-level"} ||= "INFO"
l!l
00
MC/DC0%0/1
$args->{"-level"} ||= "INFO"
$args->{"-level"}
Truth table0%0/2
A
A= $args->{"-level"}
Aresult
11
00
1094 0 ▶ $args->{-message} ||= ' - -- NO MESSAGE -- - ';
Condition0%0/2
$args->{"-message"} ||= " - -- NO MESSAGE -- - "
l!l
00
MC/DC0%0/1
$args->{"-message"} ||= " - -- NO MESSAGE -- - "
$args->{"-message"}
Truth table0%0/2
A
A= $args->{"-message"}
Aresult
11
00
1095 0 my $fh = $self->fh( %$args );
1096 0 ▶ unless ( $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh) 0 0 0
1097 0 my $log_file = $self->log_file($args->{-level});
1098  
1099 0 my $error_level = FATAL;
1100 0 ▶ if ( not $log->handle_fatals() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Easy::Log::log->handle_fatals) 0 0 0
1101 0 $error_level = ERROR;
1102 }
1103 0 $intlog->write($error_level, "No filehandle for `$args->{-level}' on $log_file");
1104 #exit 1;
1105 0 return undef;
1106 }
1107 #print "MESSAGE: $message\n";
1108 0 return $self->_WRITE( %$args, -FH => $fh );
1109 };
1110  
1111 #@f{qw(package filename line subroutine hasargs wantarray evaltext is_require hints bitmask )}=caller();
1112 1 my @showf = qw(package filename line subroutine hasargs wantarray evaltext is_require );
1113 0 ▶sub called_from {
Subroutine called_from: not called CC=4 SCAR=30.0
Pod undocumented
1114 0 my $self = shift;
1115 0 ▶ my $f = exists $_[0] ? (shift) : (( ref $self ? 2 : $self ) || 2);
Branch: 2 branches
BranchTrueFalseTotal
exists $_[0] ? : 0 0 0
ref $self ? : 0 0 0
Condition0%0/2
ref $self ? 2 : $self or 2
l!l
00
MC/DC0%0/1
ref $self ? 2 : $self or 2
ref $self ? 2 : $self
Truth table0%0/2
A
A= ref $self ? 2 : $self
Aresult
11
00
1116 0 $intlog->write($dll, '$f: ', $f );
1117 0 my $lcpa = $self->_log_called_package( $f );
1118 0 $intlog->write($dll, '$lcpa: ', $lcpa );
1119 0 my $lcp = $lcpa->[0];
1120 0 $intlog->write($dll, '$lcp: ', $lcp );
1121 0 return $lcp;
1122 }
1123  
1124 2778 ▶sub _log_called_package {
Subroutine _log_called_package: called CC=6 SCAR=18.1
1125 2778 my $self = shift;
1126 2778 ▶ my $f = shift || ( ref $self ? 0 : $self ) || 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 0 2778 2778
Condition40%2/5
shift() || (ref $self ? 0 : $self) || 0
l!l
27780
shift() or ref $self ? 0 : $self
l!l&&r!l&&!r
027780
MC/DC0%0/2
shift() || (ref $self ? 0 : $self) || 0
shift() ref $self ? 0 : $self
Truth table33%1/3
A or B
A= shift()B= ref $self ? 0 : $self
ABresult
1X1
011
000
1127 2778 my $nf = $f + 1;
1128 2778 my $log_called_package = '';
1129 2778 my $log_called_file = '';
1130 2778 my @caller = ();
1131 2778 my @f = caller($f);
1132 2778 my ( $package, $filename, $line, $subroutine ) = @f;
1133 #print '( $package, $filename, $line, $subroutine ) = ', "( $package, $filename, $line, $subroutine ) [$f]\n";
1134 2778 my @nf = caller($nf);
1135 2778 my ( $npackage, $nfilename, $nline, $nsubroutine ) = @nf;
1136 #print '( $npackage, $nfilename, $nline, $nsubroutine ) = ', "( $npackage, $nfilename, $nline, $nsubroutine ) [$nf]\n";
1137 2778 ▶ if ( $nsubroutine ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($nsubroutine) { } 926 1852 2778
elsif ($package) { } 926 926 1852
1138 926 $log_called_package = "$nsubroutine:$line";
1139 926 $log_called_file = "$filename:$line";
1140 } elsif ( $package ) {
1141 926 $log_called_package = "$package:$line";
1142 926 $log_called_file = "$filename:$line";
1143 }
1144 2778 return [ $log_called_package, $log_called_file, \@f, \@nf ];
1145 }
1146  
1147 926 ▶sub _caller {
Subroutine _caller: called CC=20 SCAR=49.6
1148 926 my $self = shift;
1149 926 ▶ my $f = shift || 0;
Condition50%1/2
shift() || 0
l!l
9260
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1150 926 my @caller = ();
1151 926 ▶ if ( $STACK_TRACE ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Easy::Log::STACK_TRACE) 0 926 926
1152 # I wonder if there is a single call to give me a stack trace like I want, I know Carp will cluck() but why didn't I use that in the first place?
1153 # did I just do my own for some easier to read formatting?
1154 0 my $s = 0;
1155 0 my %mes;
1156 0 ▶ my @mes = ({map{$mes{$_}=!$mes{$_}?length$_:($mes{$_}<length$_)?length$_:$mes{$_};($_=>$_);}@showf});
Branch: 2 branches
BranchTrueFalseTotal
!$mes{$_} ? : 0 0 0
$mes{$_} < length $_ ? : 0 0 0
1157 0 my $width = 0;
1158 0 my $depth = 0;
1159 0 while (1) {
1160 0 my %f;
1161 0 $depth = $f + ++$s;
1162 0 @f{ @showf, qw( hints bitmask )}= caller($depth);
1163 # this is probably a stupid way to break out of this loop, we basically keep stepping back up the stack until there is nothing left
1164 0 ▶ last unless join('',map{$f{$_}?$f{$_}:''}(@showf));
Branch: 2 branches
BranchTrueFalseTotal
unless join "", map({$f{$_} ? $f{$_} : "";} @showf) 0 0 0
$f{$_} ? : 0 0 0
1165 0 $width=0;
1166 0 my $x = 0;
1167 #push @mes, "$s => \n\t", join("\n\t",map{(space( $_ . "(" . $x++ . ")") . " => " . ($f{$_}?$f{$_}:'undef')) }@showf), "\n";
1168 0 ▶ foreach (@showf) {$f{$_} ||= 'undef';$mes{$_}=!$mes{$_}?length$f{$_}:($mes{$_}<length$f{$_})?length$f{$_}:$mes{$_};$width+=$mes{$_};}
Branch: 2 branches
BranchTrueFalseTotal
!$mes{$_} ? : 0 0 0
$mes{$_} < length $f{$_} ? : 0 0 0
Condition0%0/2
$f{$_} ||= "undef"
l!l
00
MC/DC0%0/1
$f{$_} ||= "undef"
$f{$_}
Truth table0%0/2
A
A= $f{$_}
Aresult
11
00
1169 0 $mes[$depth] = \%f;
1170 }
1171 0 my ($c, @c);
1172 0 my $sep = '';
1173 0 ▶ my @m = ( '_' x $width,"\n", join("", "\n", map { if($_){$c=$_;@c=map{(space($c->{$_},$mes{$_}+2,$sep) . ' | ');}@showf;$sep='';(@c,"\n");}else{()}}@mes),'_' x $width,"\n",);
Branch: 1 branch
BranchTrueFalseTotal
if ($_) { } 0 0 0
1174 0 push @caller, @m;
1175 }
1176 926 my $log_called_f = _log_called_package( $f );
1177 926 ▶ print STDERR 'log_called_f: ', $self->dump( [ $log_called_f ] ), "\n" if $ENV{LOG_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_DEBUG"} 0 926 926
1178 926 my $log_called_at = _log_called_package( $f + 1 );
1179 926 ▶ print STDERR 'log_called_at: ', $self->dump( [ $log_called_at ] ), "\n" if $ENV{LOG_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_DEBUG"} 0 926 926
1180 926 ▶ if ( not $log_called_at->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($log_called_at->[0]) 0 926 926
1181 0 $log_called_at = $log_called_f;
1182 }
1183 926 my $called_called_from = _log_called_package( $f + 2 );
1184 926 ▶ if ( not $called_called_from->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($called_called_from->[0]) 926 0 926
1185 926 $called_called_from = $log_called_at;
1186 }
1187 926 ▶ print STDERR 'log_called_f: ', $self->dump( [ $log_called_f ] ), "\n" if $ENV{LOG_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_DEBUG"} 0 926 926
1188 926 ▶ print STDERR 'log_called_at: ', $self->dump( [ $log_called_at ] ), "\n" if $ENV{LOG_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_DEBUG"} 0 926 926
1189 926 ▶ print STDERR 'called_called_from: ', $self->dump( [ $called_called_from ] ), "\n" if $ENV{LOG_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_DEBUG"} 0 926 926
1190 926 push @caller, "log call at $log_called_at->[0] in file $log_called_at->[1]";
1191 #push @caller, "$log_called_at->[0] called from $called_called_from->[0] in file $called_called_from->[1]";
1192 926 push @caller, "called from $called_called_from->[0] in file $called_called_from->[1]";
1193 926 ▶ return wantarray ? @caller : join('', @caller );
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 926 0 926
1194 }
1195  
1196 LOGS: { # a cache of open log objects for output
1197 # this may not be too desirable in the end because
1198 # you lose individual control of the log level, file ... and such
1199 # although I may be able to fix that
1200 1 my %LOGS = ( STDOUT => $this_package->object( { log_file => 'STDOUT', log_level => $log_level } ),
1201 STDIN => $this_package->object( { log_file => 'STDIN' , log_level => $log_level } ),
1202 STDERR => $this_package->object( { log_file => 'STDERR', log_level => $log_level } ),
1203 );
1204
1205 # unless otherwise specified we will use STDERR as our output stream
1206 1 $LOGS{DEFAULT} = $LOGS{$default_fh};
1207 #use Carp qw( cluck confess );
1208 #local $SIG{__WARN__} = \&cluck;
1209 #local $SIG{__DIE__} = \&confess;
1210
1211 3 ▶ sub object {
Subroutine object: called CC=11 SCAR=28.4
Pod undocumented
1212 # there should probably be a better way of specifying which existing
1213 # logging object should be used rather than REALLOG
1214 3 my $self = shift;
1215 3 ▶ my $class = ref $self || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
1216 #carp( " -- $self->object() CALLER -- " );
1217 3 ▶ $self = $class->new( @_ ) unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 3 0 3
1218
1219 3 my @args = @_;
1220 3 my $args;
1221
1222 3 ▶ if ( my $init = shift @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $init = shift @args) 3 0 3
1223 3 ▶ ref $init eq 'HASH' and $args = $init;
Branch: 1 branch
BranchTrueFalseTotal
ref $init eq "HASH" and $args = $init 3 0 3
1224 3 ▶ ref $init eq 'ARRAY' and 1;
Branch: 1 branch
BranchTrueFalseTotal
ref $init eq "ARRAY" and '???' 0 3 3
1225 }
1226 3 ▶ my $log = $args->{log} || $class || 'DEFAULT';
Condition40%2/5
$args->{'log'} || $class || 'DEFAULT'
l!l
30
$args->{"log"} or $class
l!l&&r!l&&!r
030
MC/DC0%0/2
$args->{'log'} || $class || 'DEFAULT'
$args->{"log"} $class
Truth table33%1/3
A or B
A= $args->{"log"}B= $class
ABresult
1X1
011
000
1227 3 ▶ $log = $LOGS{$log} ||= ($class eq $this_package ? $self : $this_package->new(@_));
Branch: 1 branch
BranchTrueFalseTotal
$class eq $Easy::Log::this_package ? : 1 0 1
Condition66%2/3
$LOGS{$log} ||= $class eq $Easy::Log::this_package ? $self : $Easy::Log::this_package->new(@_)
l!l&&r!l&&!r
210
MC/DC0%0/2
$LOGS{$log} ||= $class eq $Easy::Log::this_package ? $self : $Easy::Log::this_package->new(@_)
$LOGS{$log} $class eq $Easy::Log::this_package ? $self : $Easy::Log::this_package->new(@_)
Truth table66%2/3
A ||= B
A= $LOGS{$log}B= $class eq $Easy::Log::this_package ? $self : $Easy::Log::this_package->new(@_)
ABresult
1X1
011
000
1228
1229 3 ▶ return $log if $log;
Branch: 1 branch
BranchTrueFalseTotal
if $log 3 0 3
1230 # hmmm failed?
1231 0 return delete $LOGS{$log};
1232 }
1233 }
1234  
1235  
1236 #print STDERR __FILE__, ":", __LINE__, " :: \n", $log->dump( -n => [ 'FHS_NA', 'FHS_NO'], -d => [ \%FHS_NA, \%FHS_NO]), "\n";
1237 1 FILEHANDLES : { # a cache of open filehandles for output
1238 # I may want to split this into open_fh, get_fh, close_fh (with perhaps an argument helper of get_fh_file_args or something, to sort out the passed arguments for each of the potential functions mentioned )
1239 0 ▶ sub close_fh { # simply closes the current filehandle and removes if from the list of open handles
Subroutine close_fh: not called CC=6 SCAR=37.4
Pod undocumented
1240 0 my $self = shift;
1241 0 my $status = 'NA';
1242 0 ▶ if ( my $fh = $self->fh( @_, no_open => 1 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fh = $self->fh(@_, 'no_open', 1)) { } 0 0 0
1243 0 $intlog->write($dll, '$fh: ', $fh );
1244 #; # the problem here, is that if arguments were passed, and no such filehandle was already op, then fh() is going to open a filehandle, give it to us whereupon we are going to immediately close it. That kind of sucks.
1245 0 my $file_no = fileno($fh);
1246 0 my $file = $FHN_NO{$file_no};
1247 0 my $file_clean = $file;
1248 0 $file_clean =~ s/^\s*([>]{1,2})\s*//;
1249 0 ▶ if ( $ENV{LOG_DEBUG} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"LOG_DEBUG"}) 0 0 0
1250 0 print STDERR "file_no='$file_no'\n";
1251 0 print STDERR "file='$file'\n";
1252 0 print STDERR "file_clean='$file_clean'\n";
1253 }
1254 0 ▶ if ($fh and $file_no) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh and $file_no) 0 0 0
Condition0%0/3
$fh and $file_no
!ll&&!rl&&r
000
MC/DC0%0/2
$fh and $file_no
$fh $file_no
Truth table0%0/3
A and B
A= $fhB= $file_no
ABresult
0X0
100
111
1255 0 ▶ $status = close($fh) or warn "Couldn't close filehandle on '$file': $!";
Branch: 1 branch
BranchTrueFalseTotal
$status = close $fh or warn "Couldn't close filehandle on '${file}': $!" 0 0 0
1256 0 delete $FHS_NA{$file_clean};
1257 0 delete $FHS_NO{$file_no};
1258 0 delete $FHN_NO{$file_no};
1259 }
1260 } else {
1261 #$intlog->write($dl7, '@_: ', \@_ );
1262 #die;
1263 }
1264 0 return $status;
1265 }
1266 1 *get_fh = \&fh;
1267 4989 ▶ sub fh {
Subroutine fh: called CC=28 SCAR=45.5
Pod undocumented
1268 # this is a bit fucky nutty, I would like to pull all of the file handle-handling stuff into another package, I would like to add hooks for on-the-fly (de)compression, preferably all in perl (making it platform independent), but with outside programs if necessary
1269 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1270 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1271 4989 my $self = shift;
1272 #return $FHS_NA{STDERR};
1273 4989 my $args = { @_ };
1274 #print STDOUT join(" ", @_), "\n";
1275 4989 ▶ my $level = $args->{-level} || DEFAULT;
Condition50%1/2
$args->{'-level'} || 'DEFAULT'
l!l
49890
MC/DC0%0/1
$args->{'-level'} || 'DEFAULT'
$args->{'-level'}
Truth table50%1/2
A
A= $args->{'-level'}
Aresult
11
00
1276 4989 my $file;
1277 my $fh;
1278 4989 my $file_no;
1279 4989 my $file_clean;
1280 #_WRITE( "SHITBALLS", " \$level = '$level'\n" );
1281 4989 ▶ if ( $level =~ /^(STDERR|STDOUT)$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level =~ /^(STDERR|STDOUT)$/i) { } 0 4989 4989
1282 0 $fh = $FHS_NA{"\U$level"};
1283 0 $file_no = fileno($fh);
1284 0 $file = $level;
1285 0 $file_clean = $file;
1286 } else {
1287 4989 $file = $args->{"log_file_$level"};
1288 4989 ▶ $file ||= $args->{log_file};
Condition33%1/3
$file ||= $args->{"log_file"}
l!l&&r!l&&!r
049890
MC/DC0%0/2
$file ||= $args->{"log_file"}
$file $args->{"log_file"}
Truth table33%1/3
A ||= B
A= $fileB= $args->{"log_file"}
ABresult
1X1
011
000
1289 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1290 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1291 4989 ▶ $file ||= $self->{"log_file_$level"};
Condition33%1/3
$file ||= $$self{"log_file_$level"}
l!l&&r!l&&!r
498900
MC/DC0%0/2
$file ||= $$self{"log_file_$level"}
$file $$self{"log_file_$level"}
Truth table33%1/3
A ||= B
A= $fileB= $$self{"log_file_$level"}
ABresult
1X1
011
000
1292 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1293 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1294 4989 ▶ $file ||= $self->{log_file};
Condition33%1/3
$file ||= $self->{"log_file"}
l!l&&r!l&&!r
498900
MC/DC0%0/2
$file ||= $self->{"log_file"}
$file $self->{"log_file"}
Truth table33%1/3
A ||= B
A= $fileB= $self->{"log_file"}
ABresult
1X1
011
000
1295 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1296 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1297 4989 ▶ $file ||= $LEVEL_FHS{$level};
Condition33%1/3
$file ||= $Easy::Log::LEVEL_FHS{$level}
l!l&&r!l&&!r
498900
MC/DC0%0/2
$file ||= $Easy::Log::LEVEL_FHS{$level}
$file $Easy::Log::LEVEL_FHS{$level}
Truth table33%1/3
A ||= B
A= $fileB= $Easy::Log::LEVEL_FHS{$level}
ABresult
1X1
011
000
1298 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1299 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1300 4989 ▶ $file ||= $default_fh;
Condition33%1/3
$file ||= $Easy::Log::default_fh
l!l&&r!l&&!r
498900
MC/DC0%0/2
$file ||= $Easy::Log::default_fh
$file $Easy::Log::default_fh
Truth table33%1/3
A ||= B
A= $fileB= $Easy::Log::default_fh
ABresult
1X1
011
000
1301 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1302 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1303 4989 $fh = $args->{fh};# || $FHS_NA{$file_clean};
1304 # $file_clean = $file;
1305 # $file_clean =~ s/^\s*([>]{1,2})\s*//;
1306 # $fh = $args->{fh} || $FHS_NA{$file_clean};
1307 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1308 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1309 }
1310 #fileno($fh);
1311 #print STDERR __PACKAGE__, ":", __LINE__, "\n";
1312 #print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1313 #print STDERR "FH: [$level] :: ", $fh, ":", fileno($fh), " ::: $file $args->{log_file}\n";
1314 #print STDOUT "FH: [$level] :: ", $fh, ":", fileno($fh), " ::: $file $args->{log_file}\n";
1315 #print STDERR __PACKAGE__, ":", __LINE__, "FH: [$level] :: ", ($fh||'undef'), ":", " ::: $file_clean $args->{log_file}\n";
1316 #print STDOUT __PACKAGE__, ":", __LINE__, "FH: [$level] :: ", ($fh||'undef'), ":", " ::: $file_clean $args->{log_file}\n";
1317 4989 my @fhs;
1318 my $reffh;
1319 4989 ▶ if ( ref $fh eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fh eq 'ARRAY') { } 0 4989 4989
1320 0 $reffh = 1;
1321 0 @fhs = @$fh;
1322 } else {
1323 4989 $reffh = 0;
1324 4989 @fhs = $fh;
1325 }
1326 4989 my @return;
1327 4989 ▶ if ( $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh) 0 4989 4989
1328 0 foreach my $_fh ( @fhs ) {
1329 0 $file_no = fileno($_fh);
1330 #print STDERR __PACKAGE__, ":", __LINE__, "file_no: $file_no\n";
1331 #print STDOUT __PACKAGE__, ":", __LINE__, "file_no: $file_no\n";
1332 0 ▶ if ( defined $file_no ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file_no) { } 0 0 0
1333 # I don't know if I should cache this here, because we may not have been responsible for opening it
1334 #::# $FHS_NA{$file_clean} = $fh;
1335 #::# $FHN_NO{$file_no} = $file;
1336 #::# $FHS_NO{$file_no} = $fh;
1337 0 push @return, $_fh;
1338 } else {
1339 0 warn "$!: $file";
1340 }
1341 }
1342 0 ▶ return $reffh ? \@return : $return[0];
Branch: 1 branch
BranchTrueFalseTotal
$reffh ? : 0 0 0
1343 }
1344
1345 4989 my @files;
1346 my $reffile;
1347 4989 ▶ if ( ref $file eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq 'ARRAY') { } 0 4989 4989
1348 0 $reffile = 1;
1349 0 @files = @$file;
1350 } else {
1351 4989 $reffile = 0;
1352 4989 @files = $file;
1353 }
1354 #print STDERR __FILE__, ":", __LINE__, " :: \n", $self->dump( -n => [ 'FHS_NA', 'FHS_NO', 'FHN_NO'], -d => [ \%FHS_NA, \%FHS_NO, \%FHN_NO]), "\n";
1355 #print STDERR __FILE__, ":", __LINE__, " :: \n", $self->dump( -n => [ 'files'], -d => [ \@files ]), "\n";
1356 4989 foreach my $_file ( @files ) {
1357 #print STDERR __FILE__, ":", __LINE__, " :: \n", $self->dump( -n => [ '_file'], -d => [ $_file ]), "\n";
1358 4989 my $_file_clean;
1359 4989 $_file_clean = $_file;
1360 4989 $_file_clean =~ s/^\s*(\||[>]{1,2})\s*//;
1361 #print STDERR __FILE__, ":", __LINE__, " :: \n", $self->dump( -n => [ '_file_clean'], -d => [ $_file_clean ]), "\n";
1362 4989 my $_fh = $FHS_NA{$_file_clean};
1363 4989 ▶ if ( $args->{no_open} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'no_open'}) { } 0 4989 4989
1364 0 push @return, $_fh;
1365 } else {
1366 4989 ▶ unless ( $_fh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_fh) 1 4988 4989
1367 1 ▶ if ( fileno($_file) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (fileno $_file) { } 0 1 1
1368 0 $_fh = $_file;
1369 } else {
1370 1 my $mode;
1371 1 ▶ if ( $_file =~ /^\s*(\||[>]{1,2})/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_file =~ /^\s*(\||[>]{1,2})/) { } 0 1 1
1372 0 $mode = $1;
1373 } else {
1374 1 ▶ $mode = -f $_file_clean ? '>>' : '>';
Branch: 1 branch
BranchTrueFalseTotal
-f $_file_clean ? : 0 1 1
1375 }
1376 1 ▶ $_fh = new IO::File or die $!;
Branch: 1 branch
BranchTrueFalseTotal
$_fh = "IO::File"->new or die $! 1 0 1
1377 1 ▶ print STDERR "Opening new filehandle for '$_file' on '$mode' '$_file_clean'\n" if $ENV{LOG_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"LOG_DEBUG"} 0 1 1
1378 1 my $opened = $_fh->open( "$mode$_file_clean" );
1379 1 ▶ unless ( $opened ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opened) 0 1 1
1380 0 my $error_level = FATAL;
1381 0 ▶ if ( not $log->handle_fatals() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Easy::Log::log->handle_fatals) 0 0 0
1382 0 $error_level = ERROR;
1383 }
1384 0 $intlog->write($error_level, "$mode $_file_clean : $!");
1385 0 return undef;
1386 }
1387 #print STDERR "Opened new filehandle '$opened' for '$file' on '$mode' '$file_clean'\n";
1388 #print STDOUT "Opened new filehandle '$opened' for '$file' on '$mode' '$file_clean'\n";
1389 }
1390 }
1391 4989 my $_file_no = fileno($_fh);
1392 4989 ▶ defined $_file_no or die $!;
Branch: 1 branch
BranchTrueFalseTotal
defined $_file_no or die $! 4989 0 4989
1393 #print STDERR "Got fileno on new filehandle '$file_no' for '$file' on '$mode' '$file_clean'\n";
1394 #print STDOUT "Got fileno on new filehandle '$file_no' for '$file' on '$mode' '$file_clean'\n";
1395
1396 ################################################################################
1397 # this locking screwed me all up once when I was running under mod_perl
1398 # I think it was the exclusive lock collision between different httpd child processes
1399 # I should make this a per-file option I guess
1400 # in any case this wouldn't really work in an NFS environment, because there advisory locks are IPC based
1401 #my $flocked = flock $fh, LOCK_EX or die $!;
1402 #print STDERR "Got lock on new filehandle '$flocked' for '$file' on '$mode' '$file_clean'\n";
1403 #print STDOUT "Got lock on new filehandle '$flocked' for '$file' on '$mode' '$file_clean'\n";
1404 ################################################################################
1405
1406 4989 $FHS_NA{$_file_clean} = $_fh;
1407 4989 $FHS_NO{$_file_no} = $_fh;
1408 4989 $FHN_NO{$_file_no} = $_file;
1409 # print STDERR __PACKAGE__, ":", __LINE__, "\n";
1410 # print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1411 4989 ▶ ( $self->{unbuffer} or $args->{unbuffer} ) and _unbuffer( $_fh );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"unbuffer"} || $args->{"unbuffer"} and _unbuffer($_fh) 4989 0 4989
Condition33%1/3
$self->{"unbuffer"} or $args->{"unbuffer"}
l!l&&r!l&&!r
498900
MC/DC0%0/2
$self->{"unbuffer"} or $args->{"unbuffer"}
$self->{"unbuffer"} $args->{"unbuffer"}
Truth table33%1/3
A or B
A= $self->{"unbuffer"}B= $args->{"unbuffer"}
ABresult
1X1
011
000
1412 # print STDERR __PACKAGE__, ":", __LINE__, "\n";
1413 # print STDOUT __PACKAGE__, ":", __LINE__, "\n";
1414 4989 push @return, $_fh;
1415 }
1416 #print STDERR __FILE__, ":", __LINE__, " :: \n", $self->dump( -n => [ 'FHS_NA', 'FHS_NO', 'FHN_NO'], -d => [ \%FHS_NA, \%FHS_NO, \%FHN_NO]), "\n";
1417 }
1418 4989 ▶ return $reffile ? \@return : $return[0];
Branch: 1 branch
BranchTrueFalseTotal
$reffile ? : 0 4989 4989
1419 }
1420
1421 4989 ▶ sub _unbuffer {
Subroutine _unbuffer: called CC=1 SCAR=0.0
1422 4989 my $fh = shift;
1423 4989 my $selected = select;
1424 # disable buffering on this filehandle
1425 4989 select $fh; $| = 1;
1426 # restore previously selected filehandle
1427 4989 select $selected;
1428 4989 return $fh;
1429 }
1430
1431 4989 ▶ sub _WRITE {
Subroutine _WRITE: called CC=23 SCAR=44.1
1432 4989 my $self = shift;
1433 #print STDERR __FILE__, ":", __LINE__, " :: ", $self->dump([ \@_ ]), "\n";
1434 4989 my $message;
1435 my $fh;
1436 4989 my $args = {};
1437 4989 ▶ if ( $_[0] =~ /^-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /^-/) { } 4989 0 4989
1438 4989 $args = { @_ };
1439 4989 ▶ $message = $args->{-message} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$message = $args->{"-message"} or return undef 4989 0 4989
1440 4989 ▶ ref $message eq 'ARRAY' or $message = [ $message ] ;
Branch: 1 branch
BranchTrueFalseTotal
ref $message eq "ARRAY" or $message = [$message] 4989 0 4989
1441 4989 $fh = $args->{-FH};
1442 } else {
1443 0 ▶ shift @_ if ( $fh = $FHS_NA{$_[0]} );
Branch: 1 branch
BranchTrueFalseTotal
if $fh = $Easy::Log::FHS_NA{$_[0]} 0 0 0
1444 0 local $STACK_TRACE = 1;
1445 0 print STDERR __FILE__, ":", __LINE__, " :: ", $self->dump([ \@_ ]), "\n";
1446 0 ▶ $message = [ join ' ', __PACKAGE__->_caller(), map { defined $_ ? $_ : 'undef'; } @_ ] ;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
1447 0 exit 1;
1448 }
1449
1450 4989 ▶ my $level = $args->{-level} || CLEAN;
Condition50%1/2
$args->{'-level'} || 'CLEAN'
l!l
49890
MC/DC0%0/1
$args->{'-level'} || 'CLEAN'
$args->{'-level'}
Truth table50%1/2
A
A= $args->{'-level'}
Aresult
11
00
1451
1452 4989 ▶ my $return = join '', map { defined $_ ? $_ : 'undef'; } @$message;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 14966 0 14966
1453 4989 ▶ if ( $args->{-terse} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"-terse"}) 0 4989 4989
1454 0 $return =~ s/\s+/ /mg;
1455 }
1456
1457 4989 ▶ $fh ||= $FHS_NA{$default_fh};
Condition33%1/3
$fh ||= $Easy::Log::FHS_NA{$Easy::Log::default_fh}
l!l&&r!l&&!r
498900
MC/DC0%0/2
$fh ||= $Easy::Log::FHS_NA{$Easy::Log::default_fh}
$fh $Easy::Log::FHS_NA{$Easy::Log::default_fh}
Truth table33%1/3
A ||= B
A= $fhB= $Easy::Log::FHS_NA{$Easy::Log::default_fh}
ABresult
1X1
011
000
1458 4989 my @fhs;
1459 my $reffh;
1460 4989 ▶ if ( ref $fh eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fh eq 'ARRAY') { } 0 4989 4989
1461 0 $reffh = 1;
1462 0 @fhs = @$fh;
1463 } else {
1464 4989 $reffh = 0;
1465 4989 @fhs = $fh;
1466 }
1467
1468 4989 foreach my $_fh ( @fhs ) {
1469 #print STDERR __FILE__, ":", __LINE__, " :: \n", $self->dump( -n => [ 'fh', 'FHS_NA', 'FHS_NO'], -d => [ $_fh, \%FHS_NA, \%FHS_NO]), "\n";
1470 4989 ▶ fileno($_fh) or $_fh = $FHS_NA{$_fh} or die "Invalid filehandle: " . $self->dump( -n => [ 'fh' ], -d => [ $_fh ] );
Branch: 1 branch
BranchTrueFalseTotal
fileno $_fh or $_fh = $Easy::Log::FHS_NA{$_fh} or die 'Invalid filehandle: ' . $self->dump("-n", ["fh"], "-d", [$_fh]) 4989 0 4989
Condition33%1/3
fileno $_fh or $_fh = $Easy::Log::FHS_NA{$_fh}
l!l&&r!l&&!r
498900
MC/DC0%0/2
fileno $_fh or $_fh = $Easy::Log::FHS_NA{$_fh}
fileno $_fh $_fh = $Easy::Log::FHS_NA{$_fh}
Truth table33%1/3
A or B
A= fileno $_fhB= $_fh = $Easy::Log::FHS_NA{$_fh}
ABresult
1X1
011
000
1471 #_lock( $_fh );
1472 4989 ▶ print $_fh $return, $n or die ( "$!: arguments to _WRITE were => " . $self->dump( -n => [ 'args' ], -d => [ $args ] ));
Branch: 1 branch
BranchTrueFalseTotal
print $_fh $return, $Easy::Log::n or die "$!: arguments to _WRITE were => " . $self->dump("-n", ["args"], "-d", [$args]) 4989 0 4989
1473 #_unlock( $_fh );
1474 }
1475
1476 #print STDERR "level=`", ($level || 'undef'), "'\n";
1477 4989 ▶ if ( $level =~ /^(CRIT|FATAL)$/ and ( defined $args->{handle_fatals} ? $args->{handle_fatals} : $self->{handle_fatals} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($level =~ /^(CRIT|FATAL)$/ and defined $args->{"handle_fatals"} ? $args->{"handle_fatals"} : $self->{"handle_fatals"}) 0 4989 4989
defined $args->{'handle_fatals'} ? : 0 112 112
Condition66%2/3
$level =~ /^(CRIT|FATAL)$/ and defined $args->{"handle_fatals"} ? $args->{"handle_fatals"} : $self->{"handle_fatals"}
!ll&&!rl&&r
48771120
MC/DC0%0/2
$level =~ /^(CRIT|FATAL)$/ and defined $args->{"handle_fatals"} ? $args->{"handle_fatals"} : $self->{"handle_fatals"}
$level =~ /^(CRIT|FATAL)$/ defined $args->{"handle_fatals"} ? $args->{"handle_fatals"} : $self->{"handle_fatals"}
Truth table66%2/3
A and B
A= $level =~ /^(CRIT|FATAL)$/B= defined $args->{"handle_fatals"} ? $args->{"handle_fatals"} : $self->{"handle_fatals"}
ABresult
0X0
100
111
1478 0 local $STACK_TRACE = 1;
1479 0 die $self->_caller( ) . "\n$return";
1480 #die "$level\n";
1481 0 die "FATAL error! $return\n";
1482 }
1483  
1484 4989 ▶ if ( $BIG_WARN_ON{$level} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Easy::Log::BIG_WARN_ON{$level}) 0 4989 4989
1485 #print STDERR "\n\n\nDOING BIG WARN ON '$level' '$ENV{BIG_WARN_ON_FATAL}'\n\n\n";
1486 #local $STACK_TRACE = 1;
1487 0 warn $self->_caller( ) . "\n$return";
1488 #die;
1489 }
1490
1491 4989 ▶ if ( $level eq QUIT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level eq "QUIT") 56 4933 4989
1492 56 ▶ exit ($args->{QUIT} || $args->{EXIT} || $LOG_CODE{QUIT} ) unless $self->{DEBUG}{NO_QUIT};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"DEBUG"}{"NO_QUIT"} 0 56 56
Condition0%0/6
$args->{'QUIT'} || $args->{'EXIT'} || $Easy::Log::LOG_CODE{'QUIT'}
l!l&&r!l&&!r
000
$args->{"QUIT"} or $args->{"EXIT"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'QUIT'} || $args->{'EXIT'} || $Easy::Log::LOG_CODE{'QUIT'}
$args->{"QUIT"} $args->{"EXIT"} $Easy::Log::LOG_CODE{'QUIT'}
Truth table0%0/4
A or B || C
A= $args->{"QUIT"}B= $args->{"EXIT"}C= $Easy::Log::LOG_CODE{'QUIT'}
ABCresult
1XX1
01X1
0011
0000
1493 }
1494
1495 4989 return $return;
1496 }
1497 }
1498 1 ▶sub _lock {
Subroutine _lock: not called CC=1 SCAR=2.6
1499 0 my $fh = shift;
1500 #flock($fh,LOCK_EX);
1501 # and, in case someone appended
1502 # while we were waiting...
1503 0 seek($fh, 0, 2);
1504 }
1505  
1506 0 ▶sub _unlock {
Subroutine _unlock: not called CC=1 SCAR=6.9
1507 0 my $fh = shift;
1508 #flock($fh,LOCK_UN);
1509 }
1510  
1511 1 ▶sub get_userinfo {
Subroutine get_userinfo: called CC=2 SCAR=8.1
Pod undocumented
1512 1 ▶ if ( $^O =~ /mswin/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /mswin/i) { } 0 1 1
1513 0 return ( $ENV{USERNAME} );
1514 }
1515 else {
1516 1 return getpwuid $<;
1517 }
1518 }
1519  
1520 1 ▶END {
Subroutine END: called CC=1 SCAR=0.0
1521 # delete $FHS_NA{STDERR};
1522 # delete $FHS_NA{STDOUT};
1523 # foreach my $fh ( values %FHS_NA ) {
1524 # $fh->close();
1525 # }
1526 }
1527  
1528 1 1;
1529 __END__
↑ Summary Log/Filter.pm »