line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Logger::Syslog; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
4
|
|
|
4
|
|
409602
|
$Dancer::Logger::Syslog::AUTHORITY = 'cpan:SUKRIA'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Dancer logger engine for Sys::Syslog |
6
|
|
|
|
|
|
|
$Dancer::Logger::Syslog::VERSION = '0.6'; |
7
|
4
|
|
|
4
|
|
42
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
134
|
|
8
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
664
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
20
|
use base 'Dancer::Logger::Abstract'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2802
|
|
11
|
4
|
|
|
4
|
|
539606
|
use File::Basename 'basename'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
210
|
|
12
|
4
|
|
|
4
|
|
2978
|
use Sys::Syslog qw(:DEFAULT setlogsock); |
|
4
|
|
|
|
|
41614
|
|
|
4
|
|
|
|
|
763
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
35
|
use Dancer::Config 'setting'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1058
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
2
|
|
|
2
|
1
|
1670
|
my ($self) = @_; |
18
|
2
|
|
|
|
|
14
|
setlogsock('unix'); |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
1329
|
my $conf = setting('syslog'); |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
50
|
|
|
55
|
$self->{facility} = $conf->{facility} || 'USER'; |
23
|
2
|
|
33
|
|
|
16
|
$self->{ident} = $conf->{ident} |
24
|
|
|
|
|
|
|
|| setting('appname') |
25
|
|
|
|
|
|
|
|| $ENV{DANCER_APPDIR} |
26
|
|
|
|
|
|
|
|| basename($0); |
27
|
2
|
|
50
|
|
|
50
|
$self->{logopt} = $conf->{logopt} || 'pid'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
635
|
sub DESTROY { closelog() } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _log { |
33
|
7
|
|
|
7
|
|
7248
|
my ($self, $level, $message) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
100
|
|
|
|
25
|
if (!$self->{log_opened}) { |
36
|
2
|
|
|
|
|
15
|
openlog($self->{ident}, $self->{logopt}, $self->{facility}); |
37
|
2
|
|
|
|
|
732
|
$self->{log_opened} = 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
|
|
39
|
my $syslog_levels = { |
41
|
|
|
|
|
|
|
core => 'debug', |
42
|
|
|
|
|
|
|
debug => 'debug', |
43
|
|
|
|
|
|
|
warning => 'warning', |
44
|
|
|
|
|
|
|
error => 'err', |
45
|
|
|
|
|
|
|
info => 'info', |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
7
|
|
50
|
|
|
24
|
$level = $syslog_levels->{$level} || 'debug'; |
49
|
7
|
|
|
|
|
37
|
my $fm = $self->format_message($level => $message); |
50
|
7
|
|
|
|
|
1368
|
return syslog($level, $fm); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |