| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Log::Fine::Handle::Console - Output messages to C or C |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Provides logging to either C or C. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Get a new logger |
|
11
|
|
|
|
|
|
|
my $log = Log::Fine->logger("foo"); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Register a file handle |
|
14
|
|
|
|
|
|
|
my $handle = Log::Fine::Handle::Console |
|
15
|
|
|
|
|
|
|
->new( name => 'myname', |
|
16
|
|
|
|
|
|
|
mask => LOGMASK_EMERG | LOGMASK_ALERT | LOGMASK_CRIT | LOGMASK_ERR | LOGMASK_WARNING | LOGMASK_NOTICE | LOGMASK_INFO, |
|
17
|
|
|
|
|
|
|
use_stderr => undef ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# You can set logging to STDERR per preference |
|
20
|
|
|
|
|
|
|
$handle->{use_stderr} = 1; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Register the handle |
|
23
|
|
|
|
|
|
|
$log->registerHandle($handle); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Log something |
|
26
|
|
|
|
|
|
|
$log->(INFO, "Opened new log handle"); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The console handle provides logging to the console, either via |
|
31
|
|
|
|
|
|
|
C (default) or C. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
2
|
|
|
2
|
|
997
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
43
|
|
|
36
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
64
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
package Log::Fine::Handle::Console; |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
|
|
2
|
|
6
|
use base qw( Log::Fine::Handle ); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
404
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
|
|
2
|
|
7
|
use Log::Fine; |
|
|
2
|
|
|
|
|
1
|
|
|
|
2
|
|
|
|
|
245
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
our $VERSION = $Log::Fine::Handle::VERSION; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 msgWrite |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
See L |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub msgWrite |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
|
|
57
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
|
58
|
2
|
|
|
|
|
2
|
my $lvl = shift; |
|
59
|
2
|
|
|
|
|
3
|
my $msg = shift; |
|
60
|
2
|
|
|
|
|
1
|
my $skip = shift; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Should we have a formatter defined, then use that, |
|
63
|
|
|
|
|
|
|
# otherwise, just print the raw message |
|
64
|
|
|
|
|
|
|
$msg = $self->{formatter}->format($lvl, $msg, $skip) |
|
65
|
2
|
50
|
|
|
|
11
|
if defined $self->{formatter}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Where do we send the message to? |
|
68
|
2
|
100
|
|
|
|
8
|
if (defined $self->{use_stderr}) { |
|
69
|
1
|
|
|
|
|
21
|
print STDERR $msg; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
1
|
|
|
|
|
30
|
print STDOUT $msg; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
7
|
return $self; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} # msgWrite() |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# -------------------------------------------------------------------- |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
## |
|
81
|
|
|
|
|
|
|
# Initializes our object |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _init |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Perform any necessary upper class initializations |
|
89
|
1
|
|
|
|
|
7
|
$self->SUPER::_init(); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# By default, we print messages to STDOUT |
|
92
|
|
|
|
|
|
|
$self->{use_stderr} = undef |
|
93
|
1
|
50
|
|
|
|
3
|
unless (exists $self->{use_stderr}); |
|
94
|
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
1
|
return $self; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} # _init() |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 BUGS |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
102
|
|
|
|
|
|
|
C, or through the web interface at |
|
103
|
|
|
|
|
|
|
L. |
|
104
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
105
|
|
|
|
|
|
|
your bug as I make changes. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SUPPORT |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
perldoc Log::Fine |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
You can also look for information at: |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * Search CPAN |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Christopher M. Fuhrman, C<< >> |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L, L |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Copyright (c) 2008, 2010, 2013 Christopher M. Fuhrman, |
|
146
|
|
|
|
|
|
|
All rights reserved. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This program is free software licensed under the... |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The BSD License |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
153
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; # End of Log::Fine::Handle::Console |