line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Log::Fine::Levels::Syslog - Provides levels correlating to those provided by Syslog |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Defines log level values and masks correlating to those provided by |
9
|
|
|
|
|
|
|
Syslog. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Log::Fine; |
12
|
|
|
|
|
|
|
use Log::Fine::Levels::Syslog; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Grab a logging object |
15
|
|
|
|
|
|
|
my $log = Log::Fine->getLogger("foo0"); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Note that INFO and EMER are provided by the |
18
|
|
|
|
|
|
|
# Log::Fine::Levels::Syslog object |
19
|
|
|
|
|
|
|
$log->log(INFO, "I'm not mad at you, I'm mad at the dirt"); |
20
|
|
|
|
|
|
|
$log->log(EMER, "No more wire hangers ... EVER!"); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Note that this is the default class for L. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Log::Fine::Levels::Syslog provides logging and mask constants |
27
|
|
|
|
|
|
|
mimicking those provided by the classic UNIX L utility. |
28
|
|
|
|
|
|
|
This class is also used internally by the L utility for |
29
|
|
|
|
|
|
|
interpreting log levels. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
19
|
|
|
19
|
|
6516
|
use strict; |
|
19
|
|
|
|
|
21
|
|
|
19
|
|
|
|
|
464
|
|
34
|
19
|
|
|
19
|
|
62
|
use warnings; |
|
19
|
|
|
|
|
21
|
|
|
19
|
|
|
|
|
577
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package Log::Fine::Levels::Syslog; |
37
|
|
|
|
|
|
|
|
38
|
19
|
|
|
19
|
|
6870
|
use AutoLoader; |
|
19
|
|
|
|
|
17465
|
|
|
19
|
|
|
|
|
94
|
|
39
|
19
|
|
|
19
|
|
540
|
use Carp; |
|
19
|
|
|
|
|
21
|
|
|
19
|
|
|
|
|
919
|
|
40
|
19
|
|
|
19
|
|
96
|
use Exporter; |
|
19
|
|
|
|
|
20
|
|
|
19
|
|
|
|
|
508
|
|
41
|
19
|
|
|
19
|
|
61
|
use POSIX qw( strftime ); |
|
19
|
|
|
|
|
17
|
|
|
19
|
|
|
|
|
94
|
|
42
|
|
|
|
|
|
|
|
43
|
19
|
|
|
19
|
|
825
|
use base qw/ Log::Fine::Levels Exporter /; |
|
19
|
|
|
|
|
22
|
|
|
19
|
|
|
|
|
2184
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our $VERSION = $Log::Fine::Levels::VERSION; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Necessary for AutoLoader |
48
|
|
|
|
|
|
|
our $AUTOLOAD; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 Log Levels |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Log::Fine::Levels::Syslog bases its log levels on those found in |
53
|
|
|
|
|
|
|
L. The following are exported into the caller |
54
|
|
|
|
|
|
|
namespace: |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item * C |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item * C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * C |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * C |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * C |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * C |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * C |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Default level-to-value hash |
79
|
19
|
|
|
|
|
1735
|
use constant LVLTOVAL_MAP => { |
80
|
|
|
|
|
|
|
EMER => 0, |
81
|
|
|
|
|
|
|
ALRT => 1, |
82
|
|
|
|
|
|
|
CRIT => 2, |
83
|
|
|
|
|
|
|
ERR => 3, |
84
|
|
|
|
|
|
|
WARN => 4, |
85
|
|
|
|
|
|
|
NOTI => 5, |
86
|
|
|
|
|
|
|
INFO => 6, |
87
|
|
|
|
|
|
|
DEBG => 7 |
88
|
19
|
|
|
19
|
|
85
|
}; # LVLTOVAL_MAP{} |
|
19
|
|
|
|
|
20
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Default value-to-level hash |
91
|
|
|
|
|
|
|
use constant VALTOLVL_MAP => { |
92
|
|
|
|
|
|
|
LVLTOVAL_MAP->{EMER} => "EMER", |
93
|
|
|
|
|
|
|
LVLTOVAL_MAP->{ALRT} => "ALRT", |
94
|
|
|
|
|
|
|
LVLTOVAL_MAP->{CRIT} => "CRIT", |
95
|
|
|
|
|
|
|
LVLTOVAL_MAP->{ERR} => "ERR", |
96
|
|
|
|
|
|
|
LVLTOVAL_MAP->{WARN} => "WARN", |
97
|
|
|
|
|
|
|
LVLTOVAL_MAP->{NOTI} => "NOTI", |
98
|
|
|
|
|
|
|
LVLTOVAL_MAP->{INFO} => "INFO", |
99
|
19
|
|
|
|
|
1747
|
LVLTOVAL_MAP->{DEBG} => "DEBG" |
100
|
19
|
|
|
19
|
|
66
|
}; # VALTOLVL_MAP{} |
|
19
|
|
|
|
|
27
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 Log Masks |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Log masks can be exported for use in setting up individual handles |
105
|
|
|
|
|
|
|
(see L). The following masks are exported into the |
106
|
|
|
|
|
|
|
caller namespace: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * C |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * C |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * C |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * C |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * C |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * C |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * C |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * C |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
See L for more information. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
use constant MASK_MAP => { |
133
|
|
|
|
|
|
|
LOGMASK_EMERG => 2 << LVLTOVAL_MAP->{EMER}, |
134
|
|
|
|
|
|
|
LOGMASK_ALERT => 2 << LVLTOVAL_MAP->{ALRT}, |
135
|
|
|
|
|
|
|
LOGMASK_CRIT => 2 << LVLTOVAL_MAP->{CRIT}, |
136
|
|
|
|
|
|
|
LOGMASK_ERR => 2 << LVLTOVAL_MAP->{ERR}, |
137
|
|
|
|
|
|
|
LOGMASK_WARNING => 2 << LVLTOVAL_MAP->{WARN}, |
138
|
|
|
|
|
|
|
LOGMASK_NOTICE => 2 << LVLTOVAL_MAP->{NOTI}, |
139
|
|
|
|
|
|
|
LOGMASK_INFO => 2 << LVLTOVAL_MAP->{INFO}, |
140
|
19
|
|
|
19
|
|
68
|
LOGMASK_DEBUG => 2 << LVLTOVAL_MAP->{DEBG} }; # MASK_MAP{} |
|
19
|
|
|
|
|
20
|
|
|
19
|
|
|
|
|
5071
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# grab appropriate refs |
145
|
|
|
|
|
|
|
my $levels = LVLTOVAL_MAP; |
146
|
|
|
|
|
|
|
my $masks = MASK_MAP; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Exported tags |
149
|
|
|
|
|
|
|
our %EXPORT_TAGS = (macros => [ keys %{$levels} ], |
150
|
|
|
|
|
|
|
masks => [ keys %{$masks} ]); # EXPORT_TAGS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Exported macros |
153
|
|
|
|
|
|
|
our @EXPORT = (@{ $EXPORT_TAGS{macros} }); |
154
|
|
|
|
|
|
|
our @EXPORT_OK = (@{ $EXPORT_TAGS{masks} }); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# functions okay to export |
157
|
|
|
|
|
|
|
our %ok_fields = (%{$levels}, %{$masks}); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 new |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns a newly constructed object |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub new |
170
|
|
|
|
|
|
|
{ |
171
|
|
|
|
|
|
|
|
172
|
17
|
|
|
17
|
1
|
77755
|
my $class = shift; |
173
|
17
|
|
|
|
|
92
|
return bless { levelclass => $class }, $class; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
} # new() |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Autoloader |
178
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub AUTOLOAD |
181
|
|
|
|
|
|
|
{ |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Get the method name |
184
|
48
|
|
|
48
|
|
80837
|
my $name = $AUTOLOAD; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# Strip out package prefix |
187
|
48
|
|
|
|
|
208
|
$name =~ s/.*://; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# Return on DESTROY |
190
|
48
|
50
|
|
|
|
131
|
return if $name eq 'DESTROY'; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# Make sure we have a valid function |
193
|
|
|
|
|
|
|
croak( |
194
|
|
|
|
|
|
|
sprintf("[%s] {%s} FATAL : %s\n", |
195
|
|
|
|
|
|
|
strftime("%c", localtime(time)), |
196
|
|
|
|
|
|
|
$AUTOLOAD, "Invalid function name : $name" |
197
|
48
|
50
|
|
|
|
153
|
)) unless (exists $ok_fields{$name}); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# Evaluate and return the appropriate level |
200
|
48
|
|
|
47
|
1
|
2024
|
eval "sub $name { return $ok_fields{$name} }"; |
|
47
|
|
|
267
|
1
|
12704
|
|
|
267
|
|
|
167
|
1
|
83288
|
|
|
167
|
|
|
90
|
1
|
43791
|
|
|
90
|
|
|
5
|
1
|
25215
|
|
|
5
|
|
|
2
|
1
|
28
|
|
|
2
|
|
|
4
|
1
|
9
|
|
|
4
|
|
|
2
|
1
|
24
|
|
|
2
|
|
|
|
|
27
|
|
201
|
48
|
|
|
|
|
1306
|
goto &$name; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
} # AUTOLOAD() |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 BUGS |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
208
|
|
|
|
|
|
|
C, or through the web interface at |
209
|
|
|
|
|
|
|
L. |
210
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
211
|
|
|
|
|
|
|
your bug as I make changes. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 SUPPORT |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
perldoc Log::Fine::Levels::Syslog |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
You can also look for information at: |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=over 4 |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
L |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * CPAN Ratings |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
L |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * Search CPAN |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
L |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Christopher M. Fuhrman, C<< >> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 SEE ALSO |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
L, L, L, L, L |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Copyright (c) 2009, 2010, 2013 Christopher M. Fuhrman, |
252
|
|
|
|
|
|
|
All rights reserved. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This program is free software licensed under the... |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
The BSD License |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
The full text of the license can be found in the |
259
|
|
|
|
|
|
|
LICENSE file included with this module. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=cut |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
1; # End of Log::Fine::Levels::Syslog |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
__END__ |