line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Syslog::Fast::Simple; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
15388
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
104
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
281
|
use Log::Syslog::Fast ':all'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
379
|
|
7
|
2
|
|
|
2
|
|
772
|
use Sys::Hostname; |
|
2
|
|
|
|
|
1758
|
|
|
2
|
|
|
|
|
204
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
our @EXPORT = qw(); |
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = %Log::Syslog::Fast::Constants::EXPORT_TAGS; |
13
|
|
|
|
|
|
|
our @EXPORT_OK = @Log::Syslog::Fast::Constants::EXPORT_OK; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
11
|
use constant _LOGGERS => 0; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
116
|
|
16
|
2
|
|
|
2
|
|
8
|
use constant _ARGS => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
71
|
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
7
|
use constant _PROTO => 0; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
68
|
|
19
|
2
|
|
|
2
|
|
42
|
use constant _HOSTNAME => 1; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
97
|
|
20
|
2
|
|
|
2
|
|
9
|
use constant _PORT => 2; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
85
|
|
21
|
2
|
|
|
2
|
|
7
|
use constant _FACILITY => 3; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
80
|
|
22
|
2
|
|
|
2
|
|
11
|
use constant _SEVERITY => 4; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
89
|
|
23
|
2
|
|
|
2
|
|
10
|
use constant _SENDER => 5; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
92
|
|
24
|
2
|
|
|
2
|
|
9
|
use constant _NAME => 6; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
95
|
|
25
|
2
|
|
|
2
|
|
8
|
use constant _FORMAT => 7; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
902
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
2
|
|
|
2
|
1
|
881
|
my $what = shift; |
29
|
2
|
|
33
|
|
|
13
|
my $class = ref $what || $what; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
5
|
my $default_name = $0; |
32
|
2
|
|
|
|
|
12
|
$default_name =~ s,.*/,,; |
33
|
2
|
|
|
|
|
15
|
$default_name =~ s/[^\w.-_]//g; |
34
|
|
|
|
|
|
|
|
35
|
2
|
50
|
33
|
|
|
22
|
my $args = (@_ == 1 && ref $_[0] eq 'HASH') ? $_[0] : {@_}; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
50
|
|
|
11
|
$args->{proto} ||= LOG_UDP; |
38
|
2
|
|
50
|
|
|
99
|
$args->{hostname} ||= '127.0.0.1'; |
39
|
2
|
|
100
|
|
|
10
|
$args->{port} ||= 514; |
40
|
2
|
|
66
|
|
|
15
|
$args->{facility} ||= LOG_LOCAL0; |
41
|
2
|
|
66
|
|
|
11
|
$args->{severity} ||= LOG_INFO; |
42
|
2
|
|
66
|
|
|
28
|
$args->{sender} ||= Sys::Hostname::hostname; |
43
|
2
|
|
66
|
|
|
22
|
$args->{name} ||= $default_name; |
44
|
2
|
|
50
|
|
|
11
|
$args->{format} ||= LOG_RFC3164; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
17
|
return bless [ |
47
|
|
|
|
|
|
|
[], # loggers |
48
|
2
|
|
|
|
|
5
|
[@{ $args }{qw/ |
49
|
|
|
|
|
|
|
proto hostname port facility severity sender name format |
50
|
|
|
|
|
|
|
/}], |
51
|
|
|
|
|
|
|
], $class; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub send { |
55
|
2
|
|
66
|
2
|
1
|
778
|
my $severity = $_[3] || $_[0][_ARGS][_SEVERITY]; |
56
|
2
|
|
66
|
|
|
6
|
my $facility = $_[4] || $_[0][_ARGS][_FACILITY]; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
5
|
my $logger = $_[0][_LOGGERS][$facility][$severity]; |
59
|
2
|
50
|
|
|
|
4
|
if (!$logger) { |
60
|
2
|
|
|
|
|
2
|
my @args = @{ $_[0][_ARGS] }; |
|
2
|
|
|
|
|
6
|
|
61
|
2
|
|
|
|
|
3
|
$args[_FACILITY] = $facility; |
62
|
2
|
|
|
|
|
3
|
$args[_SEVERITY] = $severity; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
1
|
my $format = pop(@args); |
65
|
2
|
|
|
|
|
349
|
$logger = $_[0][_LOGGERS][$facility][$severity] = Log::Syslog::Fast->new(@args); |
66
|
2
|
|
|
|
|
31
|
$logger->set_format($format); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
66
|
|
|
106
|
return $logger->send($_[1], $_[2] || time); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |