| 1 | package Easy::Log::Filter; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | our $this_package; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | our ($FILTER_REGEX, $NOT_FILTER_REGEX, $FILTER_ALL_REGEX, $MATCH_LOG_LEVEL_REGEX, $FILTER, $NOT_FILTER, $FILTER_CNT ); | |||||||||||||||||||||||||||||||||||||||||
| 4 | # if any $(.*)log->write(...)'s are in the calling code, and the log level is specified with one of the followin prepended with a '$' | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use constant DEFAULT_FILTER => (qw( mll lll cll qll ell all wll nll ill dll tll sll ), map { "dl$_" } ( 0 .. 9, 99 )); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use constant LOG_LEVELS => ( map { $_ => "D_$_"; } qw( MESSAGE LOUD CLEAN QUIT EXIT | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | EMERG ALERT CRIT FATAL FAIL ERROR WARN NOTICE INFO DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | TRACE SPEW ), map { "DEBUG$_"} ( 0 .. 9, 99 ) | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=29 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub space { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
space: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my $sp = 'space'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | # this is a stupid little subroutine to nicely display stuff | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # could probably use a format specifier or sprintf better, but what the hell | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # I mostly use this for aligning output nicely | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $piece = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $max = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | defined $max or $max = 27; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $separator = shift; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | unless( defined $separator and length $separator > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $separator and length $separator > 0
MC/DC0%0/2
defined $separator and length $separator > 0
defined $separator
length $separator > 0
Truth table0%0/3
A and B
A= defined $separatorB= length $separator > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | $separator = ' '; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $lp = defined $piece ? length $piece : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $ls = length $separator; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $multiplier = $lp < $max ? int (( $max - $lp )/$ls ) : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $spacer = $separator x $multiplier; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $return = $sp eq 'space' ? $piece . $spacer : $spacer . $piece; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $lr = length $return; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $finisher = $lr < $max ? ( ' ' x ( $max - $lr )) : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $return = $sp eq 'space' ? ( $return . $finisher ) : ( $finisher . $return ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub pad { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pad: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $sp = 'pad'; | |||||||||||||||||||||||||||||||||||||||||
| 37 | # this is a stupid little subroutine to nicely display stuff | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # could probably use a format specifier or sprintf better, but what the hell | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # I mostly use this for aligning output nicely | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $piece = shift; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $max = shift; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | defined $max or $max = 27; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $separator = shift; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | unless( defined $separator and length $separator > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $separator and length $separator > 0
MC/DC0%0/2
defined $separator and length $separator > 0
defined $separator
length $separator > 0
Truth table0%0/3
A and B
A= defined $separatorB= length $separator > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $separator = ' '; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $lp = defined $piece ? length $piece : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $ls = length $separator; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $multiplier = $lp < $max ? int (( $max - $lp )/$ls ) : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $spacer = $separator x $multiplier; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $return = $sp eq 'space' ? $piece . $spacer : $spacer . $piece; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $lr = length $return; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $finisher = $lr < $max ? ( ' ' x ( $max - $lr )) : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $return = $sp eq 'space' ? ( $return . $finisher ) : ( $finisher . $return ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub space_pad { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
space_pad: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $sp = pop; | |||||||||||||||||||||||||||||||||||||||||
| 60 | # this is a stupid little subroutine to nicely display stuff | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # could probably use a format specifier or sprintf better, but what the hell | ||||||||||||||||||||||||||||||||||||||||||
| 62 | # I mostly use this for aligning output nicely | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $piece = shift; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $max = shift; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | defined $max or $max = 27; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $separator = shift; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | unless( defined $separator and length $separator > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $separator and length $separator > 0
MC/DC0%0/2
defined $separator and length $separator > 0
defined $separator
length $separator > 0
Truth table0%0/3
A and B
A= defined $separatorB= length $separator > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $separator = ' '; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my $lp = defined $piece ? length $piece : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $ls = length $separator; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | my $multiplier = $lp < $max ? int (( $max - $lp )/$ls ) : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $spacer = $separator x $multiplier; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $return = $sp eq 'space' ? $piece . $spacer : $spacer . $piece; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $lr = length $return; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my $finisher = $lr < $max ? ( ' ' x ( $max - $lr )) : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $return = $sp eq 'space' ? ( $return . $finisher ) : ( $finisher . $return ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | # sub space { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # space_pad( @_, 'space'); | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # sub pad { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # space_pad( @_, 'pad'); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | #die; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $this_package = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | $ENV{LOG_PACKAGES_DEBUG} ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"LOG_PACKAGES_DEBUG"} ||= 0
MC/DC0%0/1
$ENV{"LOG_PACKAGES_DEBUG"} ||= 0
$ENV{"LOG_PACKAGES_DEBUG"}
Truth table50%1/2
A
A= $ENV{"LOG_PACKAGES_DEBUG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | $ENV{LOG_FILTER_DEBUG} = exists $ENV{LOG_FILTER_DEBUG} ? $ENV{LOG_FILTER_DEBUG} : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | $ENV{LOG_FILTER_PACKAGES_DEBUG} = exists $ENV{LOG_FILTER_PACKAGES_DEBUG} ? $ENV{LOG_FILTER_PACKAGES_DEBUG} : 0; # want to make it so you can see what the filter is doing for specified packages only | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | $ENV{LOG_FILTER} ||= 'ON'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"LOG_FILTER"} ||= "ON"
MC/DC0%0/1
$ENV{"LOG_FILTER"} ||= "ON"
$ENV{"LOG_FILTER"}
Truth table50%1/2
A
A= $ENV{"LOG_FILTER"}
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | $ENV{LOG_INTERNAL_DEBUG} ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"LOG_INTERNAL_DEBUG"} ||= 0
MC/DC0%0/1
$ENV{"LOG_INTERNAL_DEBUG"} ||= 0
$ENV{"LOG_INTERNAL_DEBUG"}
Truth table50%1/2
A
A= $ENV{"LOG_INTERNAL_DEBUG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | print STDERR "THIS_PACKAGE=$this_package\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | my @DEFAULT_FILTER= DEFAULT_FILTER(); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | unless ( defined $FILTER_REGEX ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my $FILTER; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | if( $ENV{LOG_FILTER} =~ /^off$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "FILTER: IS OFF\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $FILTER = []; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $NOT_FILTER = [ @DEFAULT_FILTER ]; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } elsif( $ENV{LOG_FILTER} =~ /^(on|\d+)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "FILTER: IS ON\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | $FILTER = [ @DEFAULT_FILTER ]; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | $NOT_FILTER = []; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "FILTER: IS SPECIAL FILTER=$ENV{LOG_FILTER}\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my %not_filter = (); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my %filter = (); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | foreach my $piece ( split( /:/, $ENV{LOG_FILTER} )) { | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( $piece =~ /^\!/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $piece =~ s/^\!//; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $not_filter{$piece} = $piece; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $filter{$piece} = $piece; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "\%filter: ", scalar keys %filter , ":", join( ', ', keys %filter ), "\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "\%not_filter: ", scalar keys %not_filter, ":", join( ', ', keys %not_filter ), "\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( scalar keys %filter ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $FILTER = [ keys %filter ]; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $NOT_FILTER = []; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # $FILTER = [ map { ($not_filter{$_} and $_ =~ /$not_filter{$_}/ )? () : $_; } ( @DEFAULT_FILTER ) ]; | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # $NOT_FILTER = [ map { ($not_filter{$_} and $_ =~ /$not_filter{$_}/ )? $_ : (); } ( @DEFAULT_FILTER ) ]; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $not_filter_rx = join('|', values %not_filter); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $not_filter_rx = qr/$not_filter_rx/; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "not_filter_rx : '$not_filter_rx'\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | $FILTER = [ map { $_ =~ m/$not_filter_rx/ ? () : $_; } ( @DEFAULT_FILTER ) ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $NOT_FILTER = [ map { $_ =~ m/$not_filter_rx/ ? $_ : (); } ( @DEFAULT_FILTER ) ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "FILTER: ", join('|', @$FILTER ), "\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | #$FILTER_REGEX = '\$[_a-zA-Z]*[_a-zA-Z0-9]*log->write\(.*?\$(' . join('|', @$FILTER) . '),.*?\);'; | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | $FILTER_REGEX = '\$[_a-zA-Z]+[_a-zA-Z0-9]*->write\(.*?\$(' . join('|', @$FILTER) . '),.*?\);'; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "FILTER_REGEX : $FILTER_REGEX\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "NOT_FILTER: ", join('|', @$NOT_FILTER ), "\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | #$NOT_FILTER_REGEX = '\$[_a-zA-Z]*[_a-zA-Z0-9]*log->write\(.*?\$(' . join('|', @$NOT_FILTER) . ')(\,|\ \,|\,\ ).*?\);'; | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | $NOT_FILTER_REGEX = '\$[_a-zA-Z]+[_a-zA-Z0-9]*->write\(.*?\$(' . join('|', @$NOT_FILTER) . ')(\,|\ \,|\,\ ).*?\);'; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "NOT_FILTER_REGEX : $NOT_FILTER_REGEX\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | unless ( defined $FILTER_ALL_REGEX ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | my $FILTER = [ @DEFAULT_FILTER ]; | |||||||||||||||||||||||||||||||||||||||||
| 149 | # $FILTER_ALL_REGEX = '(\s+\$[_a-zA-Z]*[_a-zA-Z0-9]*log->write\(.*?)(' . join('|', @$FILTER) . ')(\,|\ \,|\,\ )(.*?\);)'; | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $FILTER_ALL_REGEX = '(\$[_a-zA-Z]*[_a-zA-Z0-9]*log->write\(.*?)(' . join('|', @$FILTER) . ')(\,|\ \,|\,\ )(.*?\);)'; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "FILTER_ALL_REGEX: $FILTER_ALL_REGEX\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | unless ( defined $MATCH_LOG_LEVEL_REGEX ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | my $FILTER = [ LOG_LEVELS() ]; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | $MATCH_LOG_LEVEL_REGEX = '(\$[_a-zA-Z]*[_a-zA-Z0-9]*log->write\(.*?)(' . join('|', @$FILTER) . ')(\,|\ \,|\,\ )(.*?\);)'; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "MATCH_LOG_LEVEL_REGEX: $MATCH_LOG_LEVEL_REGEX\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | use Filter::Simple; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | our $replace = '1;'; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | FILTER { # this filters out unwanted log messages from source code BEFORE COMPILATION | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=22 SCAR=40.0
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | # proves to be a great boon to performance | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | $FILTER_CNT++; | |||||||||||||||||||||||||||||||||||||||||
| 166 | ##print STDERR __LINE__, ": \$ENV{LOG_FILTER} = $ENV{LOG_FILTER}\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | return if ( $ENV{LOG_FILTER} and $ENV{LOG_FILTER} =~ /^(OFF|)$/i); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"LOG_FILTER"} and $ENV{"LOG_FILTER"} =~ /^(OFF|)$/i
MC/DC0%0/2
$ENV{"LOG_FILTER"} and $ENV{"LOG_FILTER"} =~ /^(OFF|)$/i
$ENV{"LOG_FILTER"}
$ENV{"LOG_FILTER"} =~ /^(OFF|)$/i
Truth table33%1/3
A and B
A= $ENV{"LOG_FILTER"}B= $ENV{"LOG_FILTER"} =~ /^(OFF|)$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | #return if ( $before =~ /\s*/s ); | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | my @caller = caller(1); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | ▶ | $ENV{LOG_FILTER_DEBUG} ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"LOG_FILTER_DEBUG"} ||= 0
MC/DC0%0/1
$ENV{"LOG_FILTER_DEBUG"} ||= 0
$ENV{"LOG_FILTER_DEBUG"}
Truth table50%1/2
A
A= $ENV{"LOG_FILTER_DEBUG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "CALLER: \n\t", join("\t\n", map { (defined $_ ? $_ : '')} @caller ), "\n" if ($ENV{LOG_FILTER_DEBUG} > 6); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my $package = $caller[0]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | my $file = $caller[1]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | my $calline = $caller[2]; | |||||||||||||||||||||||||||||||||||||||||
| 175 | #print STDERR "." if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | my $debug_this_package = $ENV{LOG_FILTER_PACKAGES_DEBUG} ? $file =~ /$ENV{LOG_FILTER_PACKAGES_DEBUG}/ : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "DEBUG_THIS_PACKAGE=$debug_this_package ... CALLED FROM FILE: '$file' ($ENV{LOG_FILTER_PACKAGES_DEBUG})\n" if $ENV{LOG_FILTER_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | my $not_filtered = $ENV{LOG_FILTER_DEBUG} ? "' ### LOG MESSAGE UN-FILTERABLE ### '" : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my @match; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | my @before = split("\n", $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | my @after = (); | |||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | my $linenum = $calline; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my $totallines = scalar @before; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | my $filtered = ''; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | my $filtered_status = ''; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | foreach my $line ( @before ) { | |||||||||||||||||||||||||||||||||||||||||
| 187 | 1524 | $linenum++; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 1524 | $filtered = ''; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 1524 | $filtered_status = ''; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 1524 | ▶ | if ( $line =~ /$MATCH_LOG_LEVEL_REGEX/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | $filtered_status = 'UNTOUCHED'; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } elsif ( $line =~ s/($FILTER_REGEX)\s*$/$replace/g ) { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 10 | $filtered_status = 'FILTERED '; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 10 | $filtered = $1; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } elsif ( $line =~ /$NOT_FILTER_REGEX/g ) { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $filtered_status = 'NOT-FILTERED'; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } elsif ( $line =~ /$FILTER_ALL_REGEX/ ) { #and $line !~ /$not_filtered/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", "WARNING DEBUG LOG MESSAGE NOT REMOVED: $file : $linenum: $line \n" if ($ENV{WARN_FILTER} or ( $debug_this_package and $ENV{LOG_FILTER_DEBUG})); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ENV{"WARN_FILTER"} or $debug_this_package and $ENV{"LOG_FILTER_DEBUG"}
$debug_this_package and $ENV{"LOG_FILTER_DEBUG"}
MC/DC0%0/3
$ENV{"WARN_FILTER"} or $debug_this_package and $ENV{"LOG_FILTER_DEBUG"}
$ENV{"WARN_FILTER"}
$debug_this_package
$ENV{"LOG_FILTER_DEBUG"}
Truth table0%0/4
A or B and C
A= $ENV{"WARN_FILTER"}B= $debug_this_packageC= $ENV{"LOG_FILTER_DEBUG"}
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $line =~ s/$FILTER_ALL_REGEX/${1}${2},${not_filtered}${3}${4}/; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $filtered_status = 'CHANGED'; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 1524 | push @after, $line; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 1524 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", pad(++$ENV{GLOBAL_LINES_FILTER_EXAMINED},5), ' |', pad($linenum,5), '/', space($totallines,5),': ', space($filtered_status, undef, '.'), '| ', $line, "\n" if ($debug_this_package and $ENV{LOG_FILTER_DEBUG} > 3); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$debug_this_package and $ENV{"LOG_FILTER_DEBUG"} > 3
MC/DC0%0/2
$debug_this_package and $ENV{"LOG_FILTER_DEBUG"} > 3
$debug_this_package
$ENV{"LOG_FILTER_DEBUG"} > 3
Truth table33%1/3
A and B
A= $debug_this_packageB= $ENV{"LOG_FILTER_DEBUG"} > 3
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1524 | ▶ | print STDERR __PACKAGE__, ":", __LINE__, ": ", pad('',5, 'x'), 'xx', pad('',5,'x'), 'x', space('',5,'x'),'::::: ', "FORMER CONTENTS: $filtered", "\n" if ( $debug_this_package and $ENV{LOG_FILTER_DEBUG} > 3 and $filtered ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$debug_this_package and $ENV{"LOG_FILTER_DEBUG"} > 3 and $filtered
$debug_this_package and $ENV{"LOG_FILTER_DEBUG"} > 3
MC/DC0%0/3
$debug_this_package and $ENV{"LOG_FILTER_DEBUG"} > 3 and $filtered
$debug_this_package
$ENV{"LOG_FILTER_DEBUG"} > 3
$filtered
Truth table25%1/4
A and B and C
A= $debug_this_packageB= $ENV{"LOG_FILTER_DEBUG"} > 3C= $filtered
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | $_ = join( "\n", @after) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||