line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::Log::Syslog; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12212
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
361
|
use Mojo::Base 'Mojo::Log'; |
|
1
|
|
|
|
|
6491
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
36443
|
use File::Basename 'basename'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
541
|
use Sys::Syslog qw(:DEFAULT setlogsock); |
|
1
|
|
|
|
|
12903
|
|
|
1
|
|
|
|
|
116
|
|
10
|
1
|
|
|
1
|
|
5
|
use Mojo::Util qw(encode); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
203
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'facility' => sub { 'USER' }; |
13
|
|
|
|
|
|
|
has 'ident' => sub { basename($0) }; |
14
|
|
|
|
|
|
|
has 'logopt' => sub { 'pid' }; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub append { |
17
|
0
|
|
|
0
|
1
|
|
my ($self, $msg) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
if (! $self->{log_opened}) { |
20
|
0
|
|
|
|
|
|
openlog($self->{ident}, $self->{logopt}, $self->{facility}); |
21
|
0
|
|
|
|
|
|
$self->{log_opened} = 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
my $this_level = $self->history ? $self->history->[-1]->[1] : 'debug'; # level |
25
|
0
|
|
|
|
|
|
my $syslog_levels = { |
26
|
|
|
|
|
|
|
debug => 'debug', |
27
|
|
|
|
|
|
|
info => 'info', |
28
|
|
|
|
|
|
|
warn => 'warning', |
29
|
|
|
|
|
|
|
error => 'err', |
30
|
|
|
|
|
|
|
fatal => 'err', # FIX |
31
|
|
|
|
|
|
|
}; |
32
|
0
|
|
0
|
|
|
|
my $level = $syslog_levels->{$this_level} || 'debug'; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return syslog($level, encode('UTF-8', $msg)); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
__END__ |