File Coverage

blib/lib/Log/Log4perl/JavaMap/SyslogAppender.pm
Criterion Covered Total %
statement 17 21 80.9
branch 3 8 37.5
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 24 34 70.5


line stmt bran cond sub pod time code
1              
2             use Carp;
3 1     1   8 use strict;
  1         2  
  1         85  
4 1     1   6 use Log::Dispatch::Syslog;
  1         4  
  1         23  
5 1     1   453  
  1         291469  
  1         223  
6              
7             my ($class, $appender_name, $data) = @_;
8             my $stderr;
9 1     1 0 4  
10 1         2 my ($ident, #defaults to $0
11             $logopt, #Valid options are 'cons', 'pid', 'ndelay', and 'nowait'.
12 1         3 $facility, #Valid options are 'auth', 'authpriv',
13             # 'cron', 'daemon', 'kern', 'local0' through 'local7',
14             # 'mail, 'news', 'syslog', 'user', 'uucp'. Defaults to
15             # 'user'
16             $socket, #Valid options are 'unix' or 'inet'. Defaults to 'inet'
17             );
18              
19             if (defined $data->{Facility}{value}) {
20             $facility = $data->{Facility}{value}
21 1 50       9 }elsif (defined $data->{facility}{value}){
    0          
22             $facility = $data->{facility}{value};
23 1         4 }else{
24 0         0 $facility = 'user';
25             }
26 0         0  
27             if (defined $data->{Ident}{value}) {
28             $ident = $data->{Ident}{value}
29 1 50       5 }elsif (defined $data->{ident}{value}){
    50          
30             $ident = $data->{ident}{value};
31 0         0 }else{
32 0         0 $ident = $0;
33             }
34 1         3
35             return Log::Log4perl::Appender->new("Log::Dispatch::Syslog",
36             name => $appender_name,
37 1         13 facility => $facility,
38             ident => $ident,
39             min_level => 'debug',
40             );
41             }
42              
43             1;
44              
45             =encoding utf8
46              
47             =head1 NAME
48              
49             Log::Log4perl::JavaMap::SysLogAppender - wraps Log::Dispatch::Syslog
50              
51              
52             =head1 DESCRIPTION
53              
54             This maps log4j's SyslogAppender to Log::Dispatch::Syslog
55              
56             Possible config properties for log4j SyslogAppender are
57              
58             SyslogHost (Log::Dispatch::Syslog only accepts 'localhost')
59             Facility
60              
61             Possible config properties for Log::Dispatch::Syslog are
62              
63             min_level (debug)
64             max_level
65             ident (defaults to $0)
66             logopt
67             facility
68             socket (defaults to 'inet')
69              
70             =head1 SEE ALSO
71              
72             http://jakarta.apache.org/log4j/docs/
73              
74             Log::Log4perl::Javamap
75              
76             =head1 LICENSE
77              
78             Copyright 2002-2013 by Mike Schilli E<lt>m@perlmeister.comE<gt>
79             and Kevin Goess E<lt>cpan@goess.orgE<gt>.
80              
81             This library is free software; you can redistribute it and/or modify
82             it under the same terms as Perl itself.
83              
84             =head1 AUTHOR
85              
86             Please contribute patches to the project on Github:
87              
88             http://github.com/mschilli/log4perl
89              
90             Send bug reports or requests for enhancements to the authors via our
91              
92             MAILING LIST (questions, bug reports, suggestions/patches):
93             log4perl-devel@lists.sourceforge.net
94              
95             Authors (please contact them via the list above, not directly):
96             Mike Schilli <m@perlmeister.com>,
97             Kevin Goess <cpan@goess.org>
98              
99             Contributors (in alphabetical order):
100             Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton
101             Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony
102             Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy
103             Grundman, Paul Harrington, Alexander Hartmaier David Hull,
104             Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
105             Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope,
106             Lars Thegler, David Viner, Mac Yang.
107