DRI/Logging/Syslog.pm

filter: Statementstmt 34.7% 16 / 46 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 50.0% 5 / 10 Podpod 100% 4 / 4 totaltotal 22.3% 25 / 112 CC 18 SCAR 41.0
CC
18
Cov
19%
new
132.0
setup_channel
20.0
output
20.0
CRAP 60.4
« DRI/Protocol/EPP/Extensions/E164Validation/RFC5076.pm ↑ Summary DRI/Protocol/EPP/Extensions/CentralNic/Pricing.pm »
1 ## Domain Registry Interface, SYSLOG Logging operations for Net::DRI
2 ##
3 ## Copyright (c) 2009,2013,2014 Jørgen Thomsen <netdri@jth.net>. All rights reserved
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Logging::Syslog;
16  
17 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use base qw/Net::DRI::Logging/;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Sys::Syslog qw(:DEFAULT);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 ####################################################################################################
26  
27 sub new
28 {
29 0 ▶ my ($class,$data)=@_;
Subroutine new: not called CC=11 SCAR=48.8
Pod documented
30 0 my $self=$class->SUPER::new($data);
31 0 ▶ if (! exists $self->{ident} || ! defined $self->{ident} ) { $self->{ident} = 'NetDRI'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"ident"} and defined $self->{"ident"}) 0 0 0
Condition0%0/3
exists $self->{"ident"} and defined $self->{"ident"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"ident"} and defined $self->{"ident"}
exists $self->{"ident"} defined $self->{"ident"}
Truth table0%0/3
A and B
A= exists $self->{"ident"}B= defined $self->{"ident"}
ABresult
0X0
100
111
32 0 ▶ if (! exists $self->{priority} || ! defined $self->{priority} ) { $self->{priority} = 'info'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"priority"} and defined $self->{"priority"}) 0 0 0
Condition0%0/3
exists $self->{"priority"} and defined $self->{"priority"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"priority"} and defined $self->{"priority"}
exists $self->{"priority"} defined $self->{"priority"}
Truth table0%0/3
A and B
A= exists $self->{"priority"}B= defined $self->{"priority"}
ABresult
0X0
100
111
33 0 ▶ if (! exists $self->{options} || ! defined $self->{options} ) { $self->{options} = 'pid,nofatal'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"options"} and defined $self->{"options"}) 0 0 0
Condition0%0/3
exists $self->{"options"} and defined $self->{"options"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"options"} and defined $self->{"options"}
exists $self->{"options"} defined $self->{"options"}
Truth table0%0/3
A and B
A= exists $self->{"options"}B= defined $self->{"options"}
ABresult
0X0
100
111
34 0 ▶ if (! exists $self->{facility} || ! defined $self->{facility} ) { $self->{facility} = 'local3'; }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"facility"} and defined $self->{"facility"}) 0 0 0
Condition0%0/3
exists $self->{"facility"} and defined $self->{"facility"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"facility"} and defined $self->{"facility"}
exists $self->{"facility"} defined $self->{"facility"}
Truth table0%0/3
A and B
A= exists $self->{"facility"}B= defined $self->{"facility"}
ABresult
0X0
100
111
35 0 ▶ if (! exists $self->{logopened} || ! defined $self->{logopened} ) { $self->{logopened} = 0; }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"logopened"} and defined $self->{"logopened"}) 0 0 0
Condition0%0/3
exists $self->{"logopened"} and defined $self->{"logopened"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"logopened"} and defined $self->{"logopened"}
exists $self->{"logopened"} defined $self->{"logopened"}
Truth table0%0/3
A and B
A= exists $self->{"logopened"}B= defined $self->{"logopened"}
ABresult
0X0
100
111
36 0 return $self;
37 }
38  
39 0 ▶sub name { return 'syslog'; }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
40  
41 sub setup_channel {
42 0 ▶my ($self,$source,$type,$data)=@_;
Subroutine setup_channel: not called CC=4 SCAR=30.0
Pod documented
43 0 $self->{format_header} ='[%ULEVEL] <%TYPE>';
44 # either opened by caller: 1 or opened here: 2
45 0 ▶ if (exists $self->{logopened} && defined($self->{logopened}) && $self->{logopened} > 0) { return; }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"logopened"} and defined $self->{"logopened"} and $self->{"logopened"} > 0) 0 0 0
Condition0%0/6
exists $self->{"logopened"} and defined $self->{"logopened"} and $self->{"logopened"} > 0
!ll&&!rl&&r
000
exists $self->{"logopened"} and defined $self->{"logopened"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{"logopened"} and defined $self->{"logopened"} and $self->{"logopened"} > 0
exists $self->{"logopened"} defined $self->{"logopened"} $self->{"logopened"} > 0
Truth table0%0/4
A and B and C
A= exists $self->{"logopened"}B= defined $self->{"logopened"}C= $self->{"logopened"} > 0
ABCresult
0XX0
10X0
1100
1111
46  
47 0 openlog($self->{ident}, $self->{options}, $self->{facility});
48 0 $self->{logopened} = 2;
49 0 return;
50 }
51  
52 sub output
53 {
54 0 ▶ my ($self,$level,$type,$data)=@_;
Subroutine output: not called CC=4 SCAR=30.0
Pod documented
55 0 ▶ if ($self->should_log($level)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->should_log($level)) 0 0 0
56 0 my @lines = split( /\n/, $self->tostring($level,$type,$data) ); # log each indented line when xml_indent => 1
57 0 foreach (@lines) {
58 0 ▶ syslog($self->{priority}, ($self->{logopened} != 2 ? $self->{ident}.': ':'')."%s", $_);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'logopened'} != 2 ? : 0 0 0
59 }
60 }
61 0 return;
62 }
63  
64 sub DESTROY
65 {
66 0 ▶ my ($self)=@_;
Subroutine DESTROY: not called CC=2 SCAR=17.9
67 0 ▶ closelog() if $self->{logopened} == 2; # we opened it
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"logopened"} == 2 0 0 0
68 0 return;
69 }
70 ####################################################################################################
71 1 1;
72  
73 __END__
74  
75 =pod
76  
77 =encoding utf8
78  
79 =head1 NAME
80  
81 Net::DRI::Logging::Syslog - SYSLOG Logging Operations for Net::DRI
82  
83 =head1 SYNOPSIS
84  
85 See L<Net::DRI::Logging>
86  
87 =head1 DESCRIPTION
88  
89 This class dumps all logging information to SYSLOG.
90  
91 =head1 EXAMPLES
92  
93 $dri=Net::DRI->new({cache_ttl => 10,
94 logging => ['syslog',
95 {
96 level => 'warning',
97 xml_indent => 0,
98 ident => 'NetDRI',
99 priority => 'info',
100 facility => 'local3',
101 options => 'pid,nofatal',
102 logopened => 0
103 }
104 ]
105 });
106  
107 The values above are the default
108  
109 =over 2
110  
111 =item - level, xml_ident
112  
113 refer to L<Net::DRI::Logging>
114  
115  
116 =item - ident, priority, facility, options
117  
118 refer to L<Sys::Syslog>
119  
120  
121 =item - logopened
122  
123 Value 1: Sys::Syslog::openlog() already called, so do not call it in this
124 module, but still specify ident, priority, and facility, if the defaults
125 are not wanted
126  
127 =back
128  
129 =head1 SUBROUTINES/METHODS
130  
131 All mandated by superclass L<Net::DRI::Logging>.
132  
133 =head1 DIAGNOSTICS
134  
135 None.
136  
137 =head1 CONFIGURATION AND ENVIRONMENT
138  
139 None.
140  
141 =head1 DEPENDENCIES
142  
143 This modules has to be used inside the Net::DRI framework and needs the
144 following components:
145  
146 Sys::Syslog
147  
148 =over
149  
150 =item L<Net::DRI::Logging>
151  
152 =back
153  
154 =head1 INCOMPATIBILITIES
155  
156 None
157  
158 =head1 BUGS AND LIMITATIONS
159  
160 No known bugs. Please report problems to author (see below) or use CPAN RT
161 system. Patches are welcome.
162  
163 =head1 SUPPORT
164  
165 For now, support questions should be sent to:
166  
167 E<lt>netdri@jth.netE<gt>
168  
169 Please also see the SUPPORT file in the distribution.
170  
171 =head1 SEE ALSO
172  
173 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
174  
175 =head1 AUTHOR
176  
177 Jørgen Thomsen, E<lt>netdri@jth.netE<gt>
178  
179 =head1 LICENSE AND COPYRIGHT
180  
181 Copyright (c) 2009,2013,2014 Jørgen Thomsen <netdri@jth.net>. All rights reserved.
182  
183 This program is free software; you can redistribute it and/or modify it
184 under the terms of the GNU General Public License as published by the Free
185 Software Foundation; either version 2 of the License, or (at your option)
186 any later version.
187  
188 See the LICENSE file that comes with this distribution for more details.
189  
190 =cut
« DRI/Protocol/EPP/Extensions/E164Validation/RFC5076.pm ↑ Summary DRI/Protocol/EPP/Extensions/CentralNic/Pricing.pm »