File Coverage

blib/lib/Log/Log4perl/JavaMap/FileAppender.pm
Criterion Covered Total %
statement 19 28 67.8
branch 2 14 14.2
condition 0 14 0.0
subroutine 4 4 100.0
pod 0 1 0.0
total 25 61 40.9


line stmt bran cond sub pod time code
1              
2             use Carp;
3 3     3   21 use strict;
  3         7  
  3         200  
4 3     3   18 use Log::Dispatch::File;
  3         10  
  3         98  
5 3     3   1443  
  3         217185  
  3         1101  
6              
7             my ($class, $appender_name, $data) = @_;
8             my $stderr;
9 5     5 0 17  
10 5         14 my $filename = $data->{File}{value} ||
11             $data->{filename}{value} ||
12             die "'File' not supplied for appender '$appender_name', required for a '$data->{value}'\n";
13              
14 5   0     24 my $mode;
15             if (defined($data->{Append}{value})){
16 5         7 if (lc $data->{Append}{value} eq 'true' || $data->{Append}{value} == 1){
17 5 50       29 $mode = 'append';
18 0 0 0     0 }elsif (lc $data->{Append}{value} eq 'false' || $data->{Append}{value} == 0) {
    0 0        
    0          
19 0         0 $mode = 'write';
20             }elsif($data->{Append} =~ /^(write|append)$/){
21 0         0 $mode = $data->{Append}
22             }else{
23             die "'$data->{Append}' is not a legal value for Append for appender '$appender_name', '$data->{value}'\n";
24 0         0 }
25 0         0 }else{
26             $mode = 'append';
27             }
28 5         11  
29             my $autoflush;
30             if (defined($data->{BufferedIO}{value})){
31 5         9 if (lc $data->{BufferedIO}{value} eq 'true' || $data->{BufferedIO}{value}){
32 5 50       14 $autoflush = 1;
33 0 0 0     0 }elsif (lc $data->{BufferedIO}{value} eq 'true' || ! $data->{BufferedIO}{value}) {
    0 0        
34 0         0 $autoflush = 0;
35             }else{
36 0         0 die "'$data->{BufferedIO}' is not a legal value for BufferedIO for appender '$appender_name', '$data->{value}'\n";
37             }
38 0         0 }else{
39             $autoflush = 1;
40             }
41 5         12  
42              
43             return Log::Log4perl::Appender->new("Log::Dispatch::File",
44             name => $appender_name,
45 5         38 filename => $filename,
46             mode => $mode,
47             autoflush => $autoflush,
48             );
49             }
50              
51             1;
52              
53             =encoding utf8
54              
55             =head1 NAME
56              
57             Log::Log4perl::JavaMap::FileAppender - wraps Log::Dispatch::File
58              
59             =head1 SYNOPSIS
60              
61              
62             =head1 DESCRIPTION
63              
64             Possible config properties for log4j ConsoleAppender are
65              
66             File
67             Append "true|false|1|0" default=true
68             BufferedIO "true|false|1|0" default=false (i.e. autoflush is on)
69              
70             Possible config properties for Log::Dispatch::File are
71              
72             filename
73             mode "write|append"
74             autoflush 0|1
75              
76             =head1 SEE ALSO
77              
78             http://jakarta.apache.org/log4j/docs/
79              
80             Log::Log4perl::Javamap
81              
82             Log::Dispatch::File
83              
84             =head1 LICENSE
85              
86             Copyright 2002-2013 by Mike Schilli E<lt>m@perlmeister.comE<gt>
87             and Kevin Goess E<lt>cpan@goess.orgE<gt>.
88              
89             This library is free software; you can redistribute it and/or modify
90             it under the same terms as Perl itself.
91              
92             =head1 AUTHOR
93              
94             Please contribute patches to the project on Github:
95              
96             http://github.com/mschilli/log4perl
97              
98             Send bug reports or requests for enhancements to the authors via our
99              
100             MAILING LIST (questions, bug reports, suggestions/patches):
101             log4perl-devel@lists.sourceforge.net
102              
103             Authors (please contact them via the list above, not directly):
104             Mike Schilli <m@perlmeister.com>,
105             Kevin Goess <cpan@goess.org>
106              
107             Contributors (in alphabetical order):
108             Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton
109             Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony
110             Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy
111             Grundman, Paul Harrington, Alexander Hartmaier David Hull,
112             Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
113             Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope,
114             Lars Thegler, David Viner, Mac Yang.
115