blib/lib/Log/Syslog/Fast/Simple.pm

filter: Statementstmt 100% 76 / 76 Branchbran 50.0% 2 / 4 Conditioncond 61.7% 21 / 34 MC/DCmcdc 9.5% 2 / 21 Subroutinesub 100% 16 / 16 Podpod 100% 2 / 2 totaltotal 77.7% 119 / 153 CC 16 SCAR 19.5
CC
16
Cov
87%
new
14.9
send
5.1
BEGIN
1.0
CRAP 7.0
↑ Summary blib/lib/Log/Syslog/Fast/PP.pm »
1 package Log::Syslog::Fast::Simple;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Log::Syslog::Fast ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Sys::Hostname;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 require Exporter;
10 2 our @ISA = qw(Exporter);
11 2 our @EXPORT = qw();
12 2 our %EXPORT_TAGS = %Log::Syslog::Fast::Constants::EXPORT_TAGS;
13 2 our @EXPORT_OK = @Log::Syslog::Fast::Constants::EXPORT_OK;
14  
15 2 ▶use constant _LOGGERS => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use constant _ARGS => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 ▶use constant _PROTO => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use constant _HOSTNAME => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use constant _PORT => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use constant _FACILITY => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use constant _SEVERITY => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use constant _SENDER => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use constant _NAME => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use constant _FORMAT => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 2 ▶sub new {
Subroutine new: called CC=12 SCAR=27.0
Pod documented
28 2 my $what = shift;
29 2 ▶ my $class = ref $what || $what;
Condition33%1/3
ref $what || $what
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $what || $what
ref $what $what
Truth table33%1/3
A || B
A= ref $whatB= $what
ABresult
1X1
011
000
30  
31 2 my $default_name = $0;
32 2 $default_name =~ s,.*/,,;
33 2 $default_name =~ s/[^\w.-_]//g;
34  
35 2 ▶ my $args = (@_ == 1 && ref $_[0] eq 'HASH') ? $_[0] : {@_};
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'HASH' ? : 0 2 2
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
200
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
36  
37 2 ▶ $args->{proto} ||= LOG_UDP;
Condition50%1/2
$args->{"proto"} ||= 0
l!l
02
MC/DC0%0/1
$args->{"proto"} ||= 0
$args->{"proto"}
Truth table50%1/2
A
A= $args->{"proto"}
Aresult
11
00
38 2 ▶ $args->{hostname} ||= '127.0.0.1';
Condition50%1/2
$args->{"hostname"} ||= "127.0.0.1"
l!l
02
MC/DC0%0/1
$args->{"hostname"} ||= "127.0.0.1"
$args->{"hostname"}
Truth table50%1/2
A
A= $args->{"hostname"}
Aresult
11
00
39 2 ▶ $args->{port} ||= 514;
Condition100%2/2
$args->{"port"} ||= 514
l!l
11
MC/DC100%1/1
$args->{"port"} ||= 514
$args->{"port"}
Truth table100%2/2
A
A= $args->{"port"}
Aresult
11
00
40 2 ▶ $args->{facility} ||= LOG_LOCAL0;
Condition66%2/3
$args->{"facility"} ||= LOG_LOCAL0()
l!l&&r!l&&!r
110
MC/DC0%0/2
$args->{"facility"} ||= LOG_LOCAL0()
$args->{"facility"} LOG_LOCAL0()
Truth table66%2/3
A ||= B
A= $args->{"facility"}B= LOG_LOCAL0()
ABresult
1X1
011
000
41 2 ▶ $args->{severity} ||= LOG_INFO;
Condition66%2/3
$args->{"severity"} ||= LOG_INFO()
l!l&&r!l&&!r
110
MC/DC0%0/2
$args->{"severity"} ||= LOG_INFO()
$args->{"severity"} LOG_INFO()
Truth table66%2/3
A ||= B
A= $args->{"severity"}B= LOG_INFO()
ABresult
1X1
011
000
42 2 ▶ $args->{sender} ||= Sys::Hostname::hostname;
Condition66%2/3
$args->{"sender"} ||= Sys::Hostname::hostname()
l!l&&r!l&&!r
110
MC/DC0%0/2
$args->{"sender"} ||= Sys::Hostname::hostname()
$args->{"sender"} Sys::Hostname::hostname()
Truth table66%2/3
A ||= B
A= $args->{"sender"}B= Sys::Hostname::hostname()
ABresult
1X1
011
000
43 2 ▶ $args->{name} ||= $default_name;
Condition66%2/3
$args->{"name"} ||= $default_name
l!l&&r!l&&!r
110
MC/DC0%0/2
$args->{"name"} ||= $default_name
$args->{"name"} $default_name
Truth table66%2/3
A ||= B
A= $args->{"name"}B= $default_name
ABresult
1X1
011
000
44 2 ▶ $args->{format} ||= LOG_RFC3164;
Condition50%1/2
$args->{"format"} ||= 0
l!l
02
MC/DC0%0/1
$args->{"format"} ||= 0
$args->{"format"}
Truth table50%1/2
A
A= $args->{"format"}
Aresult
11
00
45  
46 return bless [
47 [], # loggers
48 2 [@{ $args }{qw/
49 proto hostname port facility severity sender name format
50 /}],
51 ], $class;
52 }
53  
54 2 ▶sub send {
Subroutine send: called CC=5 SCAR=16.2
Pod documented
55 2 ▶ my $severity = $_[3] || $_[0][_ARGS][_SEVERITY];
Condition66%2/3
$_[3] || $_[0][1][4]
l!l&&r!l&&!r
110
MC/DC0%0/2
$_[3] || $_[0][1][4]
$_[3] $_[0][1][4]
Truth table66%2/3
A || B
A= $_[3]B= $_[0][1][4]
ABresult
1X1
011
000
56 2 ▶ my $facility = $_[4] || $_[0][_ARGS][_FACILITY];
Condition66%2/3
$_[4] || $_[0][1][3]
l!l&&r!l&&!r
110
MC/DC0%0/2
$_[4] || $_[0][1][3]
$_[4] $_[0][1][3]
Truth table66%2/3
A || B
A= $_[4]B= $_[0][1][3]
ABresult
1X1
011
000
57  
58 2 my $logger = $_[0][_LOGGERS][$facility][$severity];
59 2 ▶ if (!$logger) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($logger) 2 0 2
60 2 my @args = @{ $_[0][_ARGS] };
61 2 $args[_FACILITY] = $facility;
62 2 $args[_SEVERITY] = $severity;
63  
64 2 my $format = pop(@args);
65 2 $logger = $_[0][_LOGGERS][$facility][$severity] = Log::Syslog::Fast->new(@args);
66 2 $logger->set_format($format);
67 }
68  
69 2 ▶ return $logger->send($_[1], $_[2] || time);
Condition100%2/2
$_[2] || time
l!l
11
MC/DC100%1/1
$_[2] || time
$_[2]
Truth table100%2/2
A
A= $_[2]
Aresult
11
00
70 }
71  
72 2 1;
73 __END__
↑ Summary blib/lib/Log/Syslog/Fast/PP.pm »