| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Message::Passing::Output::Syslog; |
|
2
|
1
|
|
|
1
|
|
105624
|
use Moo; |
|
|
1
|
|
|
|
|
11188
|
|
|
|
1
|
|
|
|
|
5
|
|
|
3
|
1
|
|
|
1
|
|
2475
|
use AnyEvent; |
|
|
1
|
|
|
|
|
5411
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use Scalar::Util qw/ weaken /; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
57
|
|
|
5
|
1
|
|
|
1
|
|
490
|
use Try::Tiny qw/ try catch /; |
|
|
1
|
|
|
|
|
1345
|
|
|
|
1
|
|
|
|
|
61
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use Sys::Hostname::Long qw/ hostname_long /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
7
|
1
|
|
|
1
|
|
500
|
use Net::Syslog; |
|
|
1
|
|
|
|
|
23204
|
|
|
|
1
|
|
|
|
|
39
|
|
|
8
|
1
|
|
|
1
|
|
471
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
11461
|
|
|
|
1
|
|
|
|
|
5
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $hostname = hostname_long(); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with qw/ |
|
13
|
|
|
|
|
|
|
Message::Passing::Role::Output |
|
14
|
|
|
|
|
|
|
Message::Passing::Role::HasHostnameAndPort |
|
15
|
|
|
|
|
|
|
/; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '+hostname' => ( |
|
18
|
|
|
|
|
|
|
default => '127.0.0.1', |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
|
0
|
sub _default_port { 5140 } |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has protocol => ( |
|
24
|
|
|
|
|
|
|
isa => sub { |
|
25
|
|
|
|
|
|
|
die "$_[0] is not a valid value (tcp or udp)!" |
|
26
|
|
|
|
|
|
|
unless $_[0] eq 'tcp' || $_[0] eq 'udp'; |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
is => 'ro', |
|
29
|
|
|
|
|
|
|
default => sub { 'udp' }, |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has syslog => ( |
|
33
|
|
|
|
|
|
|
is => 'lazy', |
|
34
|
|
|
|
|
|
|
default => sub { |
|
35
|
|
|
|
|
|
|
Net::Syslog->new( |
|
36
|
|
|
|
|
|
|
SyslogHost => $_[0]->hostname, |
|
37
|
|
|
|
|
|
|
SyslogPort => $_[0]->port |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
}, |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %syslog_severities = do { my $i = 0; map { $i++ => $_ } (qw/ |
|
43
|
|
|
|
|
|
|
emergency |
|
44
|
|
|
|
|
|
|
alert |
|
45
|
|
|
|
|
|
|
critical |
|
46
|
|
|
|
|
|
|
error |
|
47
|
|
|
|
|
|
|
warning |
|
48
|
|
|
|
|
|
|
notice |
|
49
|
|
|
|
|
|
|
informational |
|
50
|
|
|
|
|
|
|
debug |
|
51
|
|
|
|
|
|
|
/) }; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my %syslog_facilities = do { my $i = 0; map { $i++ => $_ } (qw/ |
|
54
|
|
|
|
|
|
|
kernel |
|
55
|
|
|
|
|
|
|
user |
|
56
|
|
|
|
|
|
|
mail |
|
57
|
|
|
|
|
|
|
daemon |
|
58
|
|
|
|
|
|
|
auth |
|
59
|
|
|
|
|
|
|
syslog |
|
60
|
|
|
|
|
|
|
lpr |
|
61
|
|
|
|
|
|
|
news |
|
62
|
|
|
|
|
|
|
uucp |
|
63
|
|
|
|
|
|
|
cron |
|
64
|
|
|
|
|
|
|
authpriv |
|
65
|
|
|
|
|
|
|
security2 |
|
66
|
|
|
|
|
|
|
ftp |
|
67
|
|
|
|
|
|
|
NTP |
|
68
|
|
|
|
|
|
|
audit |
|
69
|
|
|
|
|
|
|
alert |
|
70
|
|
|
|
|
|
|
clock2 |
|
71
|
|
|
|
|
|
|
local0 |
|
72
|
|
|
|
|
|
|
local1 |
|
73
|
|
|
|
|
|
|
local2 |
|
74
|
|
|
|
|
|
|
local3 |
|
75
|
|
|
|
|
|
|
local4 |
|
76
|
|
|
|
|
|
|
local5 |
|
77
|
|
|
|
|
|
|
local6 |
|
78
|
|
|
|
|
|
|
local7 |
|
79
|
|
|
|
|
|
|
/) }; |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
1
|
0
|
111
|
sub consume { shift->syslog->send(@_) } |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Message::Passing::Output::Syslog - output messages to Syslog. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
message-pass --input STDIN --output Syslog --output_options '{"hostname":"127.0.0.1","port":"5140"}' |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Provides a syslogd client. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Can be used to ship syslog logs from a L<Message::Passing> system. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 hostname |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The hostname to connect to |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 port |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The port to connect to, defaults to 5140. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 protocol |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Because of the implementation of the underlying library this module currently always uses C<udp>. You are free however to set this to C<tcp> if that makes you happy. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item L<Message::Passing::Syslog> |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item L<Message::Passing> |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
See L<Message::Passing::Syslog>. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|