line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Log::Fine::Levels - Define variable logging levels |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Provides logging translations |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Log::Fine::Levels; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Instantiate the levels object using the default translations |
13
|
|
|
|
|
|
|
my $levels = Log::Fine::Levels->new(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Instantiate the levels object using customized translations |
16
|
|
|
|
|
|
|
my $levels = Log::Fine::Levels->new("Java"); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Supported methods |
19
|
|
|
|
|
|
|
my @l = $levels->logLevels(); # grab list of levels |
20
|
|
|
|
|
|
|
my @m = $levels->logMasks(); # grab list of masks |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Translation methods |
23
|
|
|
|
|
|
|
my $val = $levels->levelToValue("INFO"); |
24
|
|
|
|
|
|
|
my $bitmask = $levels->maskToValue("LOGMASK_INFO"); |
25
|
|
|
|
|
|
|
my $lvl = $levels->valueToLevel(3); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Log::Fine::Levels is used by the L framework to translate |
30
|
|
|
|
|
|
|
customizable log levels (such as INFO, DEBUG, WARNING, etc) to and |
31
|
|
|
|
|
|
|
from an associated value as well as convenience methods for |
32
|
|
|
|
|
|
|
interacting with log levels (such as grabbing a list of levels). |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
In addition, the L framework supports the notion of a |
35
|
|
|
|
|
|
|
I, which is used for customizing output. See |
36
|
|
|
|
|
|
|
L for more details as to how masks are used. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 Customization |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Log::Fine::Levels only provides methods for interacting with log |
41
|
|
|
|
|
|
|
levels and associated log masks. In order to define levels and masks, |
42
|
|
|
|
|
|
|
it I be overridden. Note that, by default, the |
43
|
|
|
|
|
|
|
L class is used to define log levels. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 Independence |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Finally, Log::Fine::Levels is written to be independant of the |
48
|
|
|
|
|
|
|
L framework and, as such, does not inherit any methods from |
49
|
|
|
|
|
|
|
L. This allows developers to use Log::Fine::Levels by |
50
|
|
|
|
|
|
|
itself for defining customizable level packages for use in their own |
51
|
|
|
|
|
|
|
programs. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
19
|
|
|
19
|
|
112
|
use strict; |
|
19
|
|
|
|
|
44
|
|
|
19
|
|
|
|
|
1400
|
|
56
|
19
|
|
|
19
|
|
104
|
use warnings; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
631
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package Log::Fine::Levels; |
59
|
|
|
|
|
|
|
|
60
|
19
|
|
|
19
|
|
104
|
use Carp; |
|
19
|
|
|
|
|
35
|
|
|
19
|
|
|
|
|
1455
|
|
61
|
19
|
|
|
19
|
|
115
|
use Log::Fine; |
|
19
|
|
|
|
|
44
|
|
|
19
|
|
|
|
|
1071
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
our $VERSION = $Log::Fine::VERSION; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Constants |
66
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
67
|
|
|
|
|
|
|
|
68
|
19
|
|
|
19
|
|
120
|
use constant DEFAULT_LEVELMAP => "Syslog"; |
|
19
|
|
|
|
|
49
|
|
|
19
|
|
|
|
|
13389
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The following methods are provided: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 new |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Creates a new Log::Fine::Levels object |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head3 Parameters |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * levelmap |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The name of the level map to use (e.g., C, C, etc) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head3 Returns |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
an L object |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub new |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
|
99
|
16
|
|
|
16
|
1
|
50
|
my $class = shift; |
100
|
16
|
|
50
|
|
|
167
|
my $lvlmap = shift || DEFAULT_LEVELMAP; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Construct the string containing name of sub-class |
103
|
16
|
|
|
|
|
63
|
my $levelClass = join("::", $class, $lvlmap); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Validate levelclass and return if successful |
106
|
16
|
|
|
|
|
1557
|
eval "require $levelClass"; |
107
|
|
|
|
|
|
|
|
108
|
16
|
50
|
|
|
|
103
|
confess "Error : Level Class $levelClass does not exist : $@" |
109
|
|
|
|
|
|
|
if $@; |
110
|
|
|
|
|
|
|
|
111
|
16
|
|
|
|
|
138
|
return $levelClass->new(); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} # new() |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 bitmaskAll |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Getter for a bitmask representing B possible values |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 Returns |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Bitmask representing all possible mask values |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub bitmaskAll |
126
|
|
|
|
|
|
|
{ |
127
|
|
|
|
|
|
|
|
128
|
26
|
|
|
26
|
1
|
72
|
my $self = shift; |
129
|
26
|
|
|
|
|
197
|
my $mask = 0; # bitmask |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# bitor all the mask values together |
132
|
26
|
|
|
|
|
52
|
$mask |= $self->MASK_MAP->{$_} foreach (keys %{ $self->MASK_MAP }); |
|
26
|
|
|
|
|
471
|
|
133
|
|
|
|
|
|
|
|
134
|
26
|
|
|
|
|
151
|
return $mask; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} # bitmaskAll() |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 levelToValue |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Level name to numeric value |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head3 Parameters |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * level name |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
The name of the level |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head3 Returns |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The numeric value representing the given level name. Undef if name is |
155
|
|
|
|
|
|
|
not defined |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
15
|
|
|
15
|
1
|
17343
|
sub levelToValue { return $_[0]->LVLTOVAL_MAP->{ $_[1] }; } |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 logLevels |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Getter for all log levels |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head3 Returns |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
An array representing all level names, sorted by ascending numeric |
168
|
|
|
|
|
|
|
value |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub logLevels |
173
|
|
|
|
|
|
|
{ |
174
|
|
|
|
|
|
|
|
175
|
2
|
|
|
2
|
1
|
10405
|
my $self = shift; |
176
|
2
|
|
|
|
|
7
|
my @lvls; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# Construct array sorted by level value (ascending) and return |
179
|
31
|
|
|
|
|
80
|
push @lvls, $self->VALTOLVL_MAP->{$_} |
180
|
2
|
|
|
|
|
5
|
foreach (sort { $a <=> $b } (keys %{ $self->VALTOLVL_MAP })); |
|
2
|
|
|
|
|
38
|
|
181
|
|
|
|
|
|
|
|
182
|
2
|
|
|
|
|
18
|
return @lvls; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} # logLevels() |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 logMasks |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Getter for all log masks |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head3 Returns |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
An array representing all mask names, sorted by ascending numeric |
193
|
|
|
|
|
|
|
value |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub logMasks |
198
|
|
|
|
|
|
|
{ |
199
|
|
|
|
|
|
|
|
200
|
4
|
|
|
4
|
1
|
27
|
my $self = shift; |
201
|
4
|
|
|
|
|
12
|
my $vtom = {}; |
202
|
4
|
|
|
|
|
10
|
my @masks; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# Build hash of mask values to mask names |
205
|
4
|
|
|
|
|
139
|
$vtom->{ $self->MASK_MAP->{$_} } = $_ |
206
|
4
|
|
|
|
|
12
|
foreach (keys %{ $self->MASK_MAP }); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# Construct array sorted by mask value (ascending) and return |
209
|
4
|
|
|
|
|
17
|
push @masks, $vtom->{$_} foreach (sort { $a <=> $b } (keys %{$vtom})); |
|
62
|
|
|
|
|
139
|
|
|
4
|
|
|
|
|
32
|
|
210
|
|
|
|
|
|
|
|
211
|
4
|
|
|
|
|
45
|
return @masks; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
} # logMasks() |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 maskToValue |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Mask name to numeric value |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head3 Parameters |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=over |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * mask name |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
The name of the mask |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=back |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head3 Returns |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
The numeric value representing the given mask name. Undef if name is |
232
|
|
|
|
|
|
|
not defined |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=cut |
235
|
|
|
|
|
|
|
|
236
|
46
|
|
|
46
|
1
|
2211
|
sub maskToValue { return $_[0]->MASK_MAP->{ $_[1] }; } |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 valueToLevel |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Level value to level name |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head3 Parameters |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=over |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item * numeric value |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
The numeric value representing a level |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=back |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head3 Returns |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
The level name associated with the given numeric value. Undef if the |
255
|
|
|
|
|
|
|
value is not defined |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=cut |
258
|
|
|
|
|
|
|
|
259
|
43
|
|
|
43
|
1
|
795
|
sub valueToLevel { return $_[0]->VALTOLVL_MAP->{ $_[1] }; } |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 BUGS |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
264
|
|
|
|
|
|
|
C, or through the web interface at |
265
|
|
|
|
|
|
|
L. |
266
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
267
|
|
|
|
|
|
|
your bug as I make changes. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 SUPPORT |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
perldoc Log::Fine::Levels |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
You can also look for information at: |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=over 4 |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
L |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=item * CPAN Ratings |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
L |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
L |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item * Search CPAN |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
L |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=back |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 AUTHOR |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Christopher M. Fuhrman, C<< >> |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 SEE ALSO |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
L, L, L, L |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Copyright (c) 2009, 2010, 2013 Christopher M. Fuhrman, |
308
|
|
|
|
|
|
|
All rights reserved. |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
This program is free software licensed under the... |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
The BSD License |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
The full text of the license can be found in the |
315
|
|
|
|
|
|
|
LICENSE file included with this module. |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
1; # End of Log::Fine::Levels |