line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Armadito::Agent::Logger::Syslog; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
11149907
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
68
|
|
5
|
1
|
|
|
1
|
|
11
|
use base 'Armadito::Agent::Logger::Backend'; |
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
445
|
|
6
|
1
|
|
|
1
|
|
6
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
1
|
50
|
|
1
|
|
618
|
if ( $OSNAME ne "linux" ) { |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Test ::Compile exception |
12
|
0
|
|
|
|
|
0
|
warn "Syslog is for unix only (OS detected : " . $OSNAME . " )"; |
13
|
0
|
|
|
|
|
0
|
exit(0); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
642
|
use Sys::Syslog qw(:standard :macros); |
|
1
|
|
|
|
|
14583
|
|
|
1
|
|
|
|
|
325
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %syslog_levels = ( |
20
|
|
|
|
|
|
|
error => LOG_ERR, |
21
|
|
|
|
|
|
|
warning => LOG_WARNING, |
22
|
|
|
|
|
|
|
info => LOG_INFO, |
23
|
|
|
|
|
|
|
debug => LOG_DEBUG, |
24
|
|
|
|
|
|
|
debug2 => LOG_DEBUG |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
0
|
|
|
0
|
1
|
|
my ( $class, %params ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $self = {}; |
31
|
0
|
|
|
|
|
|
bless $self, $class; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
openlog( "armadito-agent", 'cons,pid', $params{config}->{logfacility} ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub addMessage { |
39
|
0
|
|
|
0
|
1
|
|
my ( $self, %params ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $level = $params{level}; |
42
|
0
|
|
|
|
|
|
my $message = $params{message}; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
syslog( $syslog_levels{$level}, $message ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub DESTROY { |
48
|
0
|
|
|
0
|
|
|
closelog(); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Armadito::Agent::Logger::Syslog - A syslog backend for the logger |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This is a syslog-based backend for the logger. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 new(%params) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The constructor. The following parameters are allowed, as keys of the %params |
67
|
|
|
|
|
|
|
hash: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item I<facility> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
the syslog facility to use (default: LOG_USER) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |