blib/lib/Dancer/Logger/Syslog.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 2 / 2 Conditioncond 53.3% 8 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 80.2% 57 / 71 CC 8 SCAR 12.6
CC
8
Cov
87%
init
7.1
_log
3.0
BEGIN
1.0
CRAP 3.5
↑ Summary
1 package Dancer::Logger::Syslog;
2 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 $Dancer::Logger::Syslog::AUTHORITY = 'cpan:SUKRIA';
4 }
5 # ABSTRACT: Dancer logger engine for Sys::Syslog
6 5 $Dancer::Logger::Syslog::VERSION = '0.6';
7 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use base 'Dancer::Logger::Abstract';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use File::Basename 'basename';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Sys::Syslog qw(:DEFAULT setlogsock);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 5 ▶use Dancer::Config 'setting';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶sub init {
Subroutine init: called CC=6 SCAR=19.6
Pod documented
17 2 my ($self) = @_;
18 2 setlogsock('unix');
19  
20 2 my $conf = setting('syslog');
21  
22 2 ▶ $self->{facility} = $conf->{facility} || 'USER';
Condition50%1/2
$conf->{'facility'} || 'USER'
l!l
02
MC/DC0%0/1
$conf->{'facility'} || 'USER'
$conf->{'facility'}
Truth table50%1/2
A
A= $conf->{'facility'}
Aresult
11
00
23 $self->{ident} = $conf->{ident}
24 || setting('appname')
25 || $ENV{DANCER_APPDIR}
26 2 ▶ || basename($0);
Condition55%5/9
$conf->{'ident'} || setting('appname') || $ENV{'DANCER_APPDIR'} || basename($0)
l!l&&r!l&&!r
200
$conf->{"ident"} or setting("appname") or $ENV{"DANCER_APPDIR"}
l!l&&r!l&&!r
110
$conf->{"ident"} or setting("appname")
l!l&&r!l&&!r
011
MC/DC0%0/4
$conf->{'ident'} || setting('appname') || $ENV{'DANCER_APPDIR'} || basename($0)
$conf->{"ident"} setting("appname") $ENV{"DANCER_APPDIR"} basename($0)
Truth table40%2/5
A or B or C || D
A= $conf->{"ident"}B= setting("appname")C= $ENV{"DANCER_APPDIR"}D= basename($0)
ABCDresult
1XXX1
01XX1
001X1
00011
00000
27 2 ▶ $self->{logopt} = $conf->{logopt} || 'pid';
Condition50%1/2
$conf->{'logopt'} || 'pid'
l!l
02
MC/DC0%0/1
$conf->{'logopt'} || 'pid'
$conf->{'logopt'}
Truth table50%1/2
A
A= $conf->{'logopt'}
Aresult
11
00
28 }
29  
30 1 ▶sub DESTROY { closelog() }
Subroutine DESTROY: called CC=1 SCAR=0.0
31  
32 7 ▶sub _log {
Subroutine _log: called CC=3 SCAR=11.0
33 7 my ($self, $level, $message) = @_;
34  
35 7 ▶ if (!$self->{log_opened}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"log_opened"}) 2 5 7
36 2 openlog($self->{ident}, $self->{logopt}, $self->{facility});
37 2 $self->{log_opened} = 1;
38 }
39  
40 7 my $syslog_levels = {
41 core => 'debug',
42 debug => 'debug',
43 warning => 'warning',
44 error => 'err',
45 info => 'info',
46 };
47  
48 7 ▶ $level = $syslog_levels->{$level} || 'debug';
Condition50%1/2
$syslog_levels->{$level} || 'debug'
l!l
70
MC/DC0%0/1
$syslog_levels->{$level} || 'debug'
$syslog_levels->{$level}
Truth table50%1/2
A
A= $syslog_levels->{$level}
Aresult
11
00
49 7 my $fm = $self->format_message($level => $message);
50 7 return syslog($level, $fm);
51 }
52  
53 5 1;
54  
55 __END__
↑ Summary