Log4perl/JavaMap/RollingFileAppender.pm

filter: Statementstmt 66.6% 26 / 39 Branchbran 18.1% 4 / 22 Conditioncond 11.7% 2 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 38.7% 36 / 93 CC 18 SCAR 46.2
CC
18
Cov
41%
new
118.3
BEGIN
1.0
BEGIN
1.0
CRAP 101.5
↑ Summary Log4perl/Config/DOMConfigurator.pm »
1 package Log::Log4perl::JavaMap::RollingFileAppender;
2  
3 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Log::Dispatch::FileRotate 1.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 1 ▶sub new {
Subroutine new: called CC=18 SCAR=47.7
Pod undocumented
9 1 my ($class, $appender_name, $data) = @_;
10 1 my $stderr;
11  
12 my $filename = $data->{File}{value} ||
13 $data->{filename}{value} ||
14 1 ▶ die "'File' not supplied for appender '$appender_name', required for a '$data->{value}'\n";
Condition40%2/5
$data->{'File'}{'value'} || $data->{'filename'}{'value'} || die("'File' not supplied for appender '${appender_name}', required for a '$data->{'value'}'\n")
l!l
10
$data->{"File"}{"value"} or $data->{"filename"}{"value"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$data->{'File'}{'value'} || $data->{'filename'}{'value'} || die("'File' not supplied for appender '${appender_name}', required for a '$data->{'value'}'\n")
$data->{"File"}{"value"} $data->{"filename"}{"value"}
Truth table33%1/3
A or B
A= $data->{"File"}{"value"}B= $data->{"filename"}{"value"}
ABresult
1X1
011
000
15  
16 1 my $mode;
17 1 ▶ if (defined($data->{Append}{value})){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data->{'Append'}{'value'}) { } 0 1 1
18 0 ▶ if (lc $data->{Append}{value} eq 'true' || $data->{Append}{value} == 1){
Branch: 3 branches
BranchTrueFalseTotal
if (lc $data->{'Append'}{'value'} eq 'true' or $data->{'Append'}{'value'} == 1) { } 0 0 0
elsif (lc $data->{'Append'}{'value'} eq 'false' or $data->{'Append'}{'value'} == 0) { } 0 0 0
elsif ($data->{'Append'} =~ /^(write|append)$/) { } 0 0 0
Condition0%0/3
lc $data->{"Append"}{"value"} eq "true" or $data->{"Append"}{"value"} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $data->{"Append"}{"value"} eq "true" or $data->{"Append"}{"value"} == 1
lc $data->{"Append"}{"value"} eq "true" $data->{"Append"}{"value"} == 1
Truth table0%0/3
A or B
A= lc $data->{"Append"}{"value"} eq "true"B= $data->{"Append"}{"value"} == 1
ABresult
1X1
011
000
19 0 $mode = 'append';
20 ▶ }elsif (lc $data->{Append}{value} eq 'false' || $data->{Append}{value} == 0) {
Condition0%0/3
lc $data->{"Append"}{"value"} eq "false" or $data->{"Append"}{"value"} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $data->{"Append"}{"value"} eq "false" or $data->{"Append"}{"value"} == 0
lc $data->{"Append"}{"value"} eq "false" $data->{"Append"}{"value"} == 0
Truth table0%0/3
A or B
A= lc $data->{"Append"}{"value"} eq "false"B= $data->{"Append"}{"value"} == 0
ABresult
1X1
011
000
21 0 $mode = 'write';
22 }elsif($data->{Append} =~ /^(write|append)$/){
23 $mode = $data->{Append}
24 0 }else{
25 0 die "'$data->{Append}' is not a legal value for Append for appender '$appender_name', '$data->{value}'\n";
26 }
27 }else{
28 1 $mode = 'append';
29 }
30  
31 1 my $autoflush;
32 1 ▶ if (defined($data->{BufferedIO}{value})){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data->{'BufferedIO'}{'value'}) { } 0 1 1
33 0 ▶ if (lc $data->{BufferedIO}{value} eq 'true' || $data->{BufferedIO}{value}){
Branch: 2 branches
BranchTrueFalseTotal
if (lc $data->{'BufferedIO'}{'value'} eq 'true' or $data->{'BufferedIO'}{'value'}) { } 0 0 0
elsif (lc $data->{'BufferedIO'}{'value'} eq 'true' or not $data->{'BufferedIO'}{'value'}) { } 0 0 0
Condition0%0/3
lc $data->{"BufferedIO"}{"value"} eq "true" or $data->{"BufferedIO"}{"value"}
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $data->{"BufferedIO"}{"value"} eq "true" or $data->{"BufferedIO"}{"value"}
lc $data->{"BufferedIO"}{"value"} eq "true" $data->{"BufferedIO"}{"value"}
Truth table0%0/3
A or B
A= lc $data->{"BufferedIO"}{"value"} eq "true"B= $data->{"BufferedIO"}{"value"}
ABresult
1X1
011
000
34 0 $autoflush = 1;
35 ▶ }elsif (lc $data->{BufferedIO}{value} eq 'true' || ! $data->{BufferedIO}{value}) {
Condition0%0/3
lc $data->{"BufferedIO"}{"value"} eq "true" or not $data->{"BufferedIO"}{"value"}
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $data->{"BufferedIO"}{"value"} eq "true" or not $data->{"BufferedIO"}{"value"}
lc $data->{"BufferedIO"}{"value"} eq "true" not $data->{"BufferedIO"}{"value"}
Truth table0%0/3
A or not(B)
A= lc $data->{"BufferedIO"}{"value"} eq "true"B= not $data->{"BufferedIO"}{"value"}
ABresult
1X1
011
000
36 0 $autoflush = 0;
37 }else{
38 0 die "'$data->{BufferedIO}' is not a legal value for BufferedIO for appender '$appender_name', '$data->{value}'\n";
39 }
40 }else{
41 1 $autoflush = 1;
42 }
43  
44 1 my $max;
45 1 ▶ if (defined $data->{MaxBackupIndex}{value}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $data->{'MaxBackupIndex'}{'value'}) { } 1 0 1
elsif (defined $data->{'max'}{'value'}) { } 0 0 0
46 1 $max = $data->{MaxBackupIndex}{value};
47 }elsif (defined $data->{max}{value}){
48 0 $max = $data->{max}{value};
49 }else{
50 0 $max = 1;
51  
52 }
53  
54 1 my $size;
55 1 ▶ if (defined $data->{MaxFileSize}{value}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $data->{'MaxFileSize'}{'value'}) { } 1 0 1
elsif (defined $data->{'size'}{'value'}) { } 0 0 0
56 $size = $data->{MaxFileSize}{value}
57 1 }elsif (defined $data->{size}{value}){
58 0 $size = $data->{size}{value};
59 }else{
60 0 $size = 10_000_000;
61 }
62  
63  
64 1 return Log::Log4perl::Appender->new("Log::Dispatch::FileRotate",
65 name => $appender_name,
66 filename => $filename,
67 mode => $mode,
68 autoflush => $autoflush,
69 size => $size,
70 max => $max,
71 );
72 }
73  
74 1 1;
75  
76 =encoding utf8
77  
78 =head1 NAME
79  
80 Log::Log4perl::JavaMap::RollingFileAppender - wraps Log::Dispatch::FileRotate
81  
82 =head1 SYNOPSIS
83  
84 =head1 DESCRIPTION
85  
86 This maps log4j's RollingFileAppender to Log::Dispatch::FileRotate
87 by Mark Pfeiffer, <markpf@mlp-consulting.com.au>.
88  
89 Possible config properties for log4j ConsoleAppender are
90  
91 File
92 Append "true|false|1|0" default=true
93 BufferedIO "true|false|1|0" default=false (i.e. autoflush is on)
94 MaxFileSize default 10_000_000
95 MaxBackupIndex default is 1
96  
97 Possible config properties for Log::Dispatch::FileRotate are
98  
99 filename
100 mode "write|append"
101 autoflush 0|1
102 size
103 max
104  
105 =head1 SEE ALSO
106  
107 http://jakarta.apache.org/log4j/docs/
108  
109 Log::Log4perl::Javamap
110  
111 =head1 LICENSE
112  
113 Copyright 2002-2026 by Mike Schilli E<lt>m@perlmeister.comE<gt>
114 and Kevin Goess E<lt>cpan@goess.orgE<gt>.
115  
116 This library is free software; you can redistribute it and/or modify
117 it under the same terms as Perl itself.
↑ Summary Log4perl/Config/DOMConfigurator.pm »