line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Log::Fine::Handle - Controls where to send logging output |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Sets up an output handle for log messages |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Log::Fine; |
11
|
|
|
|
|
|
|
use Log::Fine::Handle; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Instantiate the handle (default values shown) |
14
|
|
|
|
|
|
|
my $handle = Log::Fine::Handle::Foo |
15
|
|
|
|
|
|
|
->new( name => "foo0", |
16
|
|
|
|
|
|
|
mask => Log::Fine::Handle->DEFAULT_LOGMASK, |
17
|
|
|
|
|
|
|
formatter => Log::Fine::Formatter:Basic->new() ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# See if a handle is loggable at a given level |
20
|
|
|
|
|
|
|
my $rc = $handle->isLoggable(INFO); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Write a message |
23
|
|
|
|
|
|
|
$handle->msgWrite(INFO, "Informational message", 1); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
A Log::Fine::Handle object controls I to send formatted log |
28
|
|
|
|
|
|
|
messages. The destination can be a file, syslog, a database table, or |
29
|
|
|
|
|
|
|
simply to output. Message formatting is then handled by a |
30
|
|
|
|
|
|
|
L object. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
15
|
|
|
15
|
|
5949
|
use strict; |
|
15
|
|
|
|
|
31
|
|
|
15
|
|
|
|
|
587
|
|
35
|
15
|
|
|
15
|
|
87
|
use warnings; |
|
15
|
|
|
|
|
41
|
|
|
15
|
|
|
|
|
600
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package Log::Fine::Handle; |
38
|
|
|
|
|
|
|
|
39
|
15
|
|
|
15
|
|
90
|
use base qw( Log::Fine ); |
|
15
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
2767
|
|
40
|
|
|
|
|
|
|
|
41
|
15
|
|
|
15
|
|
93
|
use Log::Fine; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
331
|
|
42
|
15
|
|
|
15
|
|
9501
|
use Log::Fine::Formatter::Basic; |
|
15
|
|
|
|
|
52
|
|
|
15
|
|
|
|
|
600
|
|
43
|
15
|
|
|
15
|
|
98
|
use Log::Fine::Levels; |
|
15
|
|
|
|
|
1263
|
|
|
15
|
|
|
|
|
9146
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our $VERSION = $Log::Fine::VERSION; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 bitmaskListEnabled |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Gets a list of enabled bit masks |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head3 Returns |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
An array containing a list of strings representing bitmasks |
56
|
|
|
|
|
|
|
enabled for this handle |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub bitmaskListEnabled |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
64
|
1
|
|
|
|
|
7
|
my $map = $self->levelMap(); |
65
|
1
|
|
|
|
|
5
|
my @bitmasks = (); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Reminder: log() here is the perl logarithmic function (see |
68
|
|
|
|
|
|
|
# perlfunc(3)) and is not to be confused with the name of this |
69
|
|
|
|
|
|
|
# module ;) |
70
|
1
|
|
|
|
|
8
|
foreach my $maskname ($map->logMasks()) { |
71
|
8
|
100
|
|
|
|
43
|
push @bitmasks, $maskname |
72
|
|
|
|
|
|
|
if $self->isLoggable( |
73
|
|
|
|
|
|
|
log($map->maskToValue($maskname)) / log(2) - 1); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
10
|
return @bitmasks; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} # bitmaskListEnabled() |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 formatter |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Getter/Setter for the objects formatter attribute |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 Parameters |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * formatter |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
B<[optional]> A valid L object |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 Returns |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
A L object |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub formatter |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
2
|
1
|
6
|
my $self = shift; |
104
|
2
|
|
|
|
|
5
|
my $formatter = shift; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Should the first argument is a valid formatter, then set the |
107
|
|
|
|
|
|
|
# objects formatter attribute appropriately |
108
|
2
|
50
|
66
|
|
|
46
|
$self->{formatter} = $formatter |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
109
|
|
|
|
|
|
|
if ( defined $formatter |
110
|
|
|
|
|
|
|
and ref $formatter |
111
|
|
|
|
|
|
|
and UNIVERSAL::can($formatter, 'isa') |
112
|
|
|
|
|
|
|
and $formatter->isa("Log::Fine::Formatter")); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# return the objects formatter attribute |
115
|
2
|
|
|
|
|
35
|
return $self->{formatter}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} # formatter() |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 isLoggable |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Specifies whether the handle is loggable at the given level. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 Parameters |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=over |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * level |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Name of level or numeric value representing level |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head3 Returns |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1 if this level is loggable, undef otherwise |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub isLoggable |
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
|
142
|
791
|
|
|
791
|
1
|
2592
|
my $self = shift; |
143
|
791
|
|
|
|
|
1341
|
my $lvl = shift; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Return undef if level is not defined |
146
|
791
|
50
|
|
|
|
10009
|
return unless defined $lvl; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Convert level to value if we are given a string, otherwise |
149
|
|
|
|
|
|
|
# use value as is. |
150
|
791
|
50
|
|
|
|
4348
|
my $val = |
151
|
|
|
|
|
|
|
($lvl =~ /^\d+$/) ? $lvl : $self->levelMap()->levelToValue($lvl); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Make sure we have a valid value |
154
|
791
|
50
|
|
|
|
8882
|
return unless defined($val); |
155
|
|
|
|
|
|
|
|
156
|
791
|
|
|
|
|
1474
|
my $shifted = 2 << $val; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# Bitand the level and the mask to see if we're loggable |
159
|
791
|
100
|
|
|
|
6543
|
return (($self->{mask} & $shifted) == $shifted) ? 1 : undef; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
} # isLoggable() |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 msgWrite |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Tells the handle to output the given log message. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
B msgWrite() is an I method to the Log::Fine |
168
|
|
|
|
|
|
|
framework, meant to be sub-classed. Use |
169
|
|
|
|
|
|
|
L for actual logging. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head3 Parameters |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=over |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * level |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Level at which to log |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * message |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Message to log |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * skip |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Passed to L for accurate method logging |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=back |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head3 Returns |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
None |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=cut |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub msgWrite |
196
|
|
|
|
|
|
|
{ |
197
|
|
|
|
|
|
|
|
198
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
199
|
1
|
|
|
|
|
4
|
my $class = ref $self; |
200
|
|
|
|
|
|
|
|
201
|
1
|
50
|
|
|
|
5
|
my $msg = |
202
|
|
|
|
|
|
|
($class eq 'Log::Fine::Handle') |
203
|
|
|
|
|
|
|
? "direct call to abstract method msgWrite()!\n See Log::Fine::Handle documentation" |
204
|
|
|
|
|
|
|
: "call to abstract method ${class}::msgWrite()"; |
205
|
|
|
|
|
|
|
|
206
|
1
|
|
|
|
|
11
|
$self->_fatal($msg); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# |
209
|
|
|
|
|
|
|
# NOT REACHED |
210
|
|
|
|
|
|
|
# |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
} # msgWrite() |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
## |
217
|
|
|
|
|
|
|
# Initializes our object |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub _init |
220
|
|
|
|
|
|
|
{ |
221
|
|
|
|
|
|
|
|
222
|
402
|
|
|
402
|
|
703
|
my $self = shift; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# Perform any necessary upper class initializations |
225
|
402
|
|
|
|
|
1972
|
$self->SUPER::_init(); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# Set default bitmask |
228
|
402
|
100
|
|
|
|
1560
|
$self->{mask} = $self->levelMap()->bitmaskAll() |
229
|
|
|
|
|
|
|
unless defined $self->{mask}; |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Set the default formatter |
232
|
402
|
50
|
66
|
|
|
2958
|
$self->{formatter} = Log::Fine::Formatter::Basic->new() |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
233
|
|
|
|
|
|
|
unless ( defined $self->{formatter} |
234
|
|
|
|
|
|
|
and ref $self->{formatter} |
235
|
|
|
|
|
|
|
and UNIVERSAL::can($self->{formatter}, 'isa') |
236
|
|
|
|
|
|
|
and $self->{formatter}->isa("Log::Fine::Formatter")); |
237
|
|
|
|
|
|
|
|
238
|
402
|
|
|
|
|
1119
|
return $self; |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
} # _init() |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 BUGS |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
245
|
|
|
|
|
|
|
C, or through the web interface at |
246
|
|
|
|
|
|
|
L. |
247
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
248
|
|
|
|
|
|
|
your bug as I make changes. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 SUPPORT |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
perldoc Log::Fine |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
You can also look for information at: |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=over 4 |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
L |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item * CPAN Ratings |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
L |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
L |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item * Search CPAN |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
L |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=back |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 AUTHOR |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Christopher M. Fuhrman, C<< >> |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 SEE ALSO |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
L, L, L |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Copyright (c) 2008, 2010-2011, 2013 Christopher M. Fuhrman, |
289
|
|
|
|
|
|
|
All rights reserved. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
This program is free software licensed under the... |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
The BSD License |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
The full text of the license can be found in the |
296
|
|
|
|
|
|
|
LICENSE file included with this module. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=cut |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
1; # End of Log::Fine::Handle |