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 0 ▶{
Subroutine new: not called CC=11 SCAR=48.8
Pod documented
29 0 my ($class,$data)=@_;
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 0 ▶sub setup_channel {
Subroutine setup_channel: not called CC=4 SCAR=30.0
Pod documented
42 0 my ($self,$source,$type,$data)=@_;
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 0 ▶{
Subroutine output: not called CC=4 SCAR=30.0
Pod documented
54 0 my ($self,$level,$type,$data)=@_;
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 0 ▶{
Subroutine DESTROY: not called CC=2 SCAR=17.9
66 0 my ($self)=@_;
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__
« DRI/Protocol/EPP/Extensions/E164Validation/RFC5076.pm ↑ Summary DRI/Protocol/EPP/Extensions/CentralNic/Pricing.pm »