| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::Log4perl::Layout::Syslog; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
218184
|
use 5.006; |
|
|
1
|
|
|
|
|
6
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
73
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
84
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use Scalar::Util; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
269
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=encoding utf8 |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Log::Log4perl::Layout::Syslog - Layout in Syslog format |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.03 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This format is useful with the Log::Dispatch::Syslog class. |
|
26
|
|
|
|
|
|
|
Add this to your configuration file: |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
log4perl.appender.A1=Log::Dispatch::Syslog |
|
29
|
|
|
|
|
|
|
log4perl.appender.A1.Filter=RangeAll |
|
30
|
|
|
|
|
|
|
log4perl.appender.A1.ident=bandsman |
|
31
|
|
|
|
|
|
|
log4perl.appender.A1.layout=Log::Log4perl::Layout::Syslog |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Much of the actual formatting is done by the Sys::Syslog code called |
|
34
|
|
|
|
|
|
|
from Log::Dispatch::Syslog, |
|
35
|
|
|
|
|
|
|
however you can't use Log::Log4perl::Layout::NoopLayout |
|
36
|
|
|
|
|
|
|
since that doesn't insert the ident data that's needed by systems such as |
|
37
|
|
|
|
|
|
|
flutentd. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 new |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use Log::Log4perl::Layout::Syslog; |
|
44
|
|
|
|
|
|
|
my $layout = Log::Log4perl::Layout::Syslog->new(); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
|
49
|
1
|
|
|
1
|
1
|
245806
|
my $class = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
9
|
if(!defined($class)) { |
|
|
|
50
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Using Log::Log4perl::Layout::Syslog->new(), not Log::Log4perl::Layout::Syslog::new() |
|
53
|
|
|
|
|
|
|
# carp(__PACKAGE__, ' use ->new() not ::new() to instantiate'); |
|
54
|
|
|
|
|
|
|
# return; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# FIXME: this only works when no arguments are given |
|
57
|
0
|
|
|
|
|
0
|
$class = __PACKAGE__; |
|
58
|
|
|
|
|
|
|
} elsif(Scalar::Util::blessed($class)) { |
|
59
|
|
|
|
|
|
|
# If $class is an object, clone it with new arguments |
|
60
|
|
|
|
|
|
|
# return bless { %{$class}, %args }, ref($class); |
|
61
|
0
|
|
|
|
|
0
|
return bless { %{$class} }, ref($class); |
|
|
0
|
|
|
|
|
0
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Return the blessed object |
|
65
|
1
|
|
|
|
|
8
|
return bless { |
|
66
|
|
|
|
|
|
|
info_needed => {}, |
|
67
|
|
|
|
|
|
|
stack => [], |
|
68
|
|
|
|
|
|
|
}, $class; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 render |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Render a message in the correct format. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub render { |
|
78
|
|
|
|
|
|
|
# my($self, $message, $category, $priority, $caller_level) = @_; |
|
79
|
1
|
|
|
1
|
1
|
753
|
my $message = $_[1]; |
|
80
|
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
12
|
return "user: $message"; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Nigel Horne, C<< >> |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 BUGS |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
I can't work out how to get the ident given to |
|
91
|
|
|
|
|
|
|
Log::Dispatch::Syslog's constructor, |
|
92
|
|
|
|
|
|
|
so ident (facility in RFC3164 lingo) is always sent to |
|
93
|
|
|
|
|
|
|
LOG_USER. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L |
|
98
|
|
|
|
|
|
|
L |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SUPPORT |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
perldoc Log-Log4perl-Layout-Syslog |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
You can also look for information at: |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * Search CPAN |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright 2017-2014 Nigel Horne. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is released under the following licence: GPL2 |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |