Log4perl/Filter/StringMatch.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 96.0% 48 / 50 CC 2 SCAR 1.8
CC
2
Cov
100%
ok
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Log4perl/Layout/SimpleLayout.pm ↑ Summary Log4perl/Filter/LevelMatch.pm »
1 ##################################################
2 package Log::Log4perl::Filter::StringMatch;
3 ##################################################
4  
5 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Log::Log4perl::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Log::Log4perl::Util qw( params_check );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use constant _INTERNAL_DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use base "Log::Log4perl::Filter";
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 ##################################################
18 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
19 ##################################################
20 3 my ($class, %options) = @_;
21  
22 3 print join('-', %options) if _INTERNAL_DEBUG;
23  
24 3 my $self = { StringToMatch => undef,
25 AcceptOnMatch => 1,
26 %options,
27 };
28
29 3 params_check( $self,
30 [ qw( StringToMatch ) ],
31 [ qw( name AcceptOnMatch ) ]
32 );
33  
34 $self->{AcceptOnMatch} = Log::Log4perl::Config::boolean_to_perlish(
35 3 $self->{AcceptOnMatch});
36  
37 3 $self->{StringToMatch} = qr($self->{StringToMatch});
38  
39 3 bless $self, $class;
40  
41 3 return $self;
42 }
43  
44 ##################################################
45 9 ▶sub ok {
Subroutine ok: called CC=2 SCAR=6.9
Pod undocumented
46 ##################################################
47 9 my ($self, %p) = @_;
48  
49 local($_) = join $
50 9 Log::Log4perl::JOIN_MSG_ARRAY_CHAR, @{$p{message}};
51  
52 9 ▶ if($_ =~ $self->{StringToMatch}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /$self->{'StringToMatch'}/) { } 5 4 9
53 5 print "Strings match\n" if _INTERNAL_DEBUG;
54 5 return $self->{AcceptOnMatch};
55 } else {
56 4 print "Strings don't match ($_/$self->{StringToMatch})\n"
57 if _INTERNAL_DEBUG;
58 4 return !$self->{AcceptOnMatch};
59 }
60 }
61  
62 1 1;
63  
64 __END__
« Log4perl/Layout/SimpleLayout.pm ↑ Summary Log4perl/Filter/LevelMatch.pm »