line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Syslog::Fast::Simple; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
20519
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
424
|
use Log::Syslog::Fast ':all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
539
|
|
7
|
2
|
|
|
2
|
|
8651
|
use Sys::Hostname; |
|
2
|
|
|
|
|
1732
|
|
|
2
|
|
|
|
|
194
|
|
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
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
100
|
|
16
|
2
|
|
|
2
|
|
8
|
use constant _ARGS => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
65
|
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
8
|
use constant _PROTO => 0; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
62
|
|
19
|
2
|
|
|
2
|
|
7
|
use constant _HOSTNAME => 1; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
80
|
|
20
|
2
|
|
|
2
|
|
8
|
use constant _PORT => 2; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
76
|
|
21
|
2
|
|
|
2
|
|
8
|
use constant _FACILITY => 3; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
84
|
|
22
|
2
|
|
|
2
|
|
14
|
use constant _SEVERITY => 4; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
99
|
|
23
|
2
|
|
|
2
|
|
11
|
use constant _SENDER => 5; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
89
|
|
24
|
2
|
|
|
2
|
|
10
|
use constant _NAME => 6; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
95
|
|
25
|
2
|
|
|
2
|
|
10
|
use constant _FORMAT => 7; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
958
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
2
|
|
|
2
|
1
|
909
|
my $what = shift; |
29
|
2
|
|
33
|
|
|
12
|
my $class = ref $what || $what; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
5
|
my $default_name = $0; |
32
|
2
|
|
|
|
|
13
|
$default_name =~ s,.*/,,; |
33
|
2
|
|
|
|
|
14
|
$default_name =~ s/[^\w.-_]//g; |
34
|
|
|
|
|
|
|
|
35
|
2
|
50
|
33
|
|
|
21
|
my $args = (@_ == 1 && ref $_[0] eq 'HASH') ? $_[0] : {@_}; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
50
|
|
|
11
|
$args->{proto} ||= LOG_UDP; |
38
|
2
|
|
50
|
|
|
13
|
$args->{hostname} ||= '127.0.0.1'; |
39
|
2
|
|
100
|
|
|
7
|
$args->{port} ||= 514; |
40
|
2
|
|
66
|
|
|
12
|
$args->{facility} ||= LOG_LOCAL0; |
41
|
2
|
|
66
|
|
|
13
|
$args->{severity} ||= LOG_INFO; |
42
|
2
|
|
66
|
|
|
12
|
$args->{sender} ||= Sys::Hostname::hostname; |
43
|
2
|
|
66
|
|
|
22
|
$args->{name} ||= $default_name; |
44
|
2
|
|
50
|
|
|
11
|
$args->{format} ||= LOG_RFC3164; |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
18
|
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
|
1076
|
my $severity = $_[3] || $_[0][_ARGS][_SEVERITY]; |
56
|
2
|
|
66
|
|
|
10
|
my $facility = $_[4] || $_[0][_ARGS][_FACILITY]; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
6
|
my $logger = $_[0][_LOGGERS][$facility][$severity]; |
59
|
2
|
50
|
|
|
|
5
|
if (!$logger) { |
60
|
2
|
|
|
|
|
3
|
my @args = @{ $_[0][_ARGS] }; |
|
2
|
|
|
|
|
8
|
|
61
|
2
|
|
|
|
|
4
|
$args[_FACILITY] = $facility; |
62
|
2
|
|
|
|
|
3
|
$args[_SEVERITY] = $severity; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
5
|
my $format = pop(@args); |
65
|
2
|
|
|
|
|
403
|
$logger = $_[0][_LOGGERS][$facility][$severity] = Log::Syslog::Fast->new(@args); |
66
|
2
|
|
|
|
|
48
|
$logger->set_format($format); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
2
|
|
66
|
|
|
138
|
return $logger->send($_[1], $_[2] || time); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |