| 1 | package Log::Log4perl::Config::BaseConfigurator; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 54 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 54 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 54 | ▶ | use constant _INTERNAL_DEBUG => 0; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 54 | *eval_if_perl = \&Log::Log4perl::Config::eval_if_perl; | |||||||||||||||||||||||||||||||||||||
| 8 | 54 | *compile_if_perl = \&Log::Log4perl::Config::compile_if_perl; | |||||||||||||||||||||||||||||||||||||
| 9 | 54 | *leaf_path_to_hash = \&Log::Log4perl::Config::leaf_path_to_hash; | |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 12 | 316 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 13 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 14 | 316 | my($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | 316 | my $self = { | |||||||||||||||||||||||||||||||||||||
| 17 | utf8 => 0, | ||||||||||||||||||||||||||||||||||||||
| 18 | %options, | ||||||||||||||||||||||||||||||||||||||
| 19 | }; | ||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | 316 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 316 | ▶ | $self->file($self->{file}) if exists $self->{file}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 24 | 316 | ▶ | $self->text($self->{text}) if exists $self->{text}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | 316 | return $self; | |||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 30 | 168 | ▶ | sub text { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
text: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 31 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 32 | 168 | my($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | # $text is an array of scalars (lines) | ||||||||||||||||||||||||||||||||||||||
| 35 | 168 | ▶ | if(defined $text) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 36 | 153 | ▶ | if(ref $text eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 37 | 153 | $self->{text} = $text; | |||||||||||||||||||||||||||||||||||||
| 38 | } else { | ||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{text} = [split "\n", $text]; | |||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | 168 | return $self->{text}; | |||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 47 | 17 | ▶ | sub file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
file: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 48 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 49 | 17 | my($self, $filename) = @_; | |||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | 17 | ▶ | open my $fh, "$filename" or die "Cannot open $filename ($!)"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | 15 | ▶ | if( $self->{ utf8 } ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | binmode $fh, ":utf8"; | |||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | 15 | $self->file_h_read( $fh ); | |||||||||||||||||||||||||||||||||||||
| 58 | 15 | close $fh; | |||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 62 | 16 | ▶ | sub file_h_read { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
file_h_read: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 63 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 64 | 16 | my($self, $fh) = @_; | |||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | # Dennis Gregorovic <dgregor@redhat.com> added this | ||||||||||||||||||||||||||||||||||||||
| 67 | # to protect apps which are tinkering with $/ globally. | ||||||||||||||||||||||||||||||||||||||
| 68 | 16 | local $/ = "\n"; | |||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||
| 70 | 16 | $self->{text} = [<$fh>]; | |||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 75 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 76 | 0 | die __PACKAGE__ . "::parse() is a virtual method. " . | |||||||||||||||||||||||||||||||||||||
| 77 | "It must be implemented " . | ||||||||||||||||||||||||||||||||||||||
| 78 | "in a derived class (currently: ", ref(shift), ")"; | ||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||
| 81 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 82 | 148 | ▶ | sub parse_post_process { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_post_process: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 83 | ################################################ | ||||||||||||||||||||||||||||||||||||||
| 84 | 148 | my($self, $data, $leaf_paths) = @_; | |||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | # [ | ||||||||||||||||||||||||||||||||||||||
| 87 | # 'category', | ||||||||||||||||||||||||||||||||||||||
| 88 | # 'value', | ||||||||||||||||||||||||||||||||||||||
| 89 | # 'WARN, Logfile' | ||||||||||||||||||||||||||||||||||||||
| 90 | # ], | ||||||||||||||||||||||||||||||||||||||
| 91 | # [ | ||||||||||||||||||||||||||||||||||||||
| 92 | # 'appender', | ||||||||||||||||||||||||||||||||||||||
| 93 | # 'Logfile', | ||||||||||||||||||||||||||||||||||||||
| 94 | # 'value', | ||||||||||||||||||||||||||||||||||||||
| 95 | # 'Log::Log4perl::Appender::File' | ||||||||||||||||||||||||||||||||||||||
| 96 | # ], | ||||||||||||||||||||||||||||||||||||||
| 97 | # [ | ||||||||||||||||||||||||||||||||||||||
| 98 | # 'appender', | ||||||||||||||||||||||||||||||||||||||
| 99 | # 'Logfile', | ||||||||||||||||||||||||||||||||||||||
| 100 | # 'filename', | ||||||||||||||||||||||||||||||||||||||
| 101 | # 'value', | ||||||||||||||||||||||||||||||||||||||
| 102 | # 'test.log' | ||||||||||||||||||||||||||||||||||||||
| 103 | # ], | ||||||||||||||||||||||||||||||||||||||
| 104 | # [ | ||||||||||||||||||||||||||||||||||||||
| 105 | # 'appender', | ||||||||||||||||||||||||||||||||||||||
| 106 | # 'Logfile', | ||||||||||||||||||||||||||||||||||||||
| 107 | # 'layout', | ||||||||||||||||||||||||||||||||||||||
| 108 | # 'value', | ||||||||||||||||||||||||||||||||||||||
| 109 | # 'Log::Log4perl::Layout::PatternLayout' | ||||||||||||||||||||||||||||||||||||||
| 110 | # ], | ||||||||||||||||||||||||||||||||||||||
| 111 | # [ | ||||||||||||||||||||||||||||||||||||||
| 112 | # 'appender', | ||||||||||||||||||||||||||||||||||||||
| 113 | # 'Logfile', | ||||||||||||||||||||||||||||||||||||||
| 114 | # 'layout', | ||||||||||||||||||||||||||||||||||||||
| 115 | # 'ConversionPattern', | ||||||||||||||||||||||||||||||||||||||
| 116 | # 'value', | ||||||||||||||||||||||||||||||||||||||
| 117 | # '%d %F{1} %L> %m %n' | ||||||||||||||||||||||||||||||||||||||
| 118 | # ] | ||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | 148 | for my $path ( @{ Log::Log4perl::Config::leaf_paths( $data )} ) { | |||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||
| 122 | 882 | print "path=@$path\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||
| 124 | 882 | ▶ | if(0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||
| 125 | ▶ | } elsif( | |||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$path->[0] eq "appender" and $path->[2] eq "trigger"
MC/DC100%2/2
$path->[0] eq "appender" and $path->[2] eq "trigger"
$path->[0] eq "appender"
$path->[2] eq "trigger"
Truth table100%3/3
A and B
A= $path->[0] eq "appender"B= $path->[2] eq "trigger"
| |||||||||||||||||||||||||||||||||||||||
| 126 | $path->[0] eq "appender" and | ||||||||||||||||||||||||||||||||||||||
| 127 | $path->[2] eq "trigger" | ||||||||||||||||||||||||||||||||||||||
| 128 | ) { | ||||||||||||||||||||||||||||||||||||||
| 129 | 2 | my $ref = leaf_path_to_hash( $path, $data ); | |||||||||||||||||||||||||||||||||||||
| 130 | 2 | my $code = compile_if_perl( $$ref ); | |||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | 2 | if(_INTERNAL_DEBUG) { | |||||||||||||||||||||||||||||||||||||
| 133 | if($code) { | ||||||||||||||||||||||||||||||||||||||
| 134 | print "Code compiled: $$ref\n"; | ||||||||||||||||||||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||||||||||||||||||||
| 136 | print "Not compiled: $$ref\n"; | ||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | 2 | ▶ | $$ref = $code if defined $code; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 141 | } elsif ( | ||||||||||||||||||||||||||||||||||||||
| 142 | $path->[0] eq "filter" | ||||||||||||||||||||||||||||||||||||||
| 143 | ) { | ||||||||||||||||||||||||||||||||||||||
| 144 | # do nothing | ||||||||||||||||||||||||||||||||||||||
| 145 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$path->[0] eq "appender" and $path->[2] eq "warp_message"
MC/DC100%2/2
$path->[0] eq "appender" and $path->[2] eq "warp_message"
$path->[0] eq "appender"
$path->[2] eq "warp_message"
Truth table100%3/3
A and B
A= $path->[0] eq "appender"B= $path->[2] eq "warp_message"
| |||||||||||||||||||||||||||||||||||||||
| 146 | $path->[0] eq "appender" and | ||||||||||||||||||||||||||||||||||||||
| 147 | $path->[2] eq "warp_message" | ||||||||||||||||||||||||||||||||||||||
| 148 | ) { | ||||||||||||||||||||||||||||||||||||||
| 149 | # do nothing | ||||||||||||||||||||||||||||||||||||||
| 150 | ▶ | } elsif ( | |||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$path->[0] eq "appender" and $path->[3] eq "cspec" or $path->[1] eq "cspec"
$path->[0] eq "appender" and $path->[3] eq "cspec"
MC/DC100%3/3
$path->[0] eq "appender" and $path->[3] eq "cspec" or $path->[1] eq "cspec"
$path->[0] eq "appender"
$path->[3] eq "cspec"
$path->[1] eq "cspec"
Truth table80%4/5
A and B or C
A= $path->[0] eq "appender"B= $path->[3] eq "cspec"C= $path->[1] eq "cspec"
| |||||||||||||||||||||||||||||||||||||||
| 151 | $path->[0] eq "appender" and | ||||||||||||||||||||||||||||||||||||||
| 152 | $path->[3] eq "cspec" or | ||||||||||||||||||||||||||||||||||||||
| 153 | $path->[1] eq "cspec" | ||||||||||||||||||||||||||||||||||||||
| 154 | ) { | ||||||||||||||||||||||||||||||||||||||
| 155 | # could be either | ||||||||||||||||||||||||||||||||||||||
| 156 | # appender appndr layout cspec | ||||||||||||||||||||||||||||||||||||||
| 157 | # or | ||||||||||||||||||||||||||||||||||||||
| 158 | # PatternLayout cspec U value ... | ||||||||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||||||||
| 160 | # do nothing | ||||||||||||||||||||||||||||||||||||||
| 161 | } else { | ||||||||||||||||||||||||||||||||||||||
| 162 | 806 | my $ref = leaf_path_to_hash( $path, $data ); | |||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | 806 | if(_INTERNAL_DEBUG) { | |||||||||||||||||||||||||||||||||||||
| 165 | print "Calling eval_if_perl on $$ref\n"; | ||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | 806 | $$ref = eval_if_perl( $$ref ); | |||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||
| 172 | 144 | return $data; | |||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | 54 | 1; | |||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | __END__ | ||||||||||||||||||||||||||||||||||||||