| 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'
MC/DC0%0/1
$conf->{'facility'} || 'USER'
$conf->{'facility'}
Truth table50%1/2
A
A= $conf->{'facility'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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)
$conf->{"ident"} or setting("appname") or $ENV{"DANCER_APPDIR"}
$conf->{"ident"} or setting("appname")
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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | $self->{logopt} = $conf->{logopt} || 'pid'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'logopt'} || 'pid'
MC/DC0%0/1
$conf->{'logopt'} || 'pid'
$conf->{'logopt'}
Truth table50%1/2
A
A= $conf->{'logopt'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$syslog_levels->{$level} || 'debug'
$syslog_levels->{$level}
Truth table50%1/2
A
A= $syslog_levels->{$level}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 7 | my $fm = $self->format_message($level => $message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 7 | return syslog($level, $fm); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||