line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Log; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
520
|
use 5.018; |
|
3
|
|
|
|
|
10
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
61
|
|
6
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
86
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
15
|
use Venus::Class 'attr', 'base', 'with'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
19
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Venus::Kind::Utility'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Venus::Role::Buildable'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ATTRIBUTES |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
attr 'handler'; |
17
|
|
|
|
|
|
|
attr 'level'; |
18
|
|
|
|
|
|
|
attr 'separator'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# STATE |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
state $NAME = {trace => 1, debug => 2, info => 3, warn => 4, error => 5, fatal => 6}; |
23
|
|
|
|
|
|
|
state $CODE = {reverse %$NAME}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# BUILDERS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub build_arg { |
28
|
2
|
|
|
2
|
0
|
8
|
my ($self, $data) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return { |
31
|
2
|
|
33
|
|
|
7
|
level => $self->level_name($data) || $self->level_name(1), |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub build_args { |
36
|
54
|
|
|
54
|
0
|
117
|
my ($self, $data) = @_; |
37
|
|
|
|
|
|
|
|
38
|
54
|
|
66
|
|
|
217
|
$data->{level} ||= $self->level_name(1); |
39
|
|
|
|
|
|
|
|
40
|
54
|
|
|
|
|
188
|
return $data; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub build_self { |
44
|
54
|
|
|
54
|
0
|
128
|
my ($self, $data) = @_; |
45
|
|
|
|
|
|
|
|
46
|
54
|
100
|
|
0
|
|
148
|
$self->handler(sub{shift; CORE::print(STDOUT @_, "\n")}) if !$self->handler; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
47
|
54
|
50
|
|
|
|
170
|
$self->separator(" ") if !$self->separator; |
48
|
|
|
|
|
|
|
|
49
|
54
|
|
|
|
|
147
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub commit { |
55
|
26
|
|
|
26
|
0
|
74
|
my ($self, $level, @args) = @_; |
56
|
|
|
|
|
|
|
|
57
|
26
|
|
|
|
|
74
|
my $req_level = $self->level_code($level); |
58
|
26
|
|
|
|
|
86
|
my $set_level = $self->level_code($self->level); |
59
|
|
|
|
|
|
|
|
60
|
26
|
100
|
100
|
|
|
312
|
return ($req_level && $set_level && ($req_level >= $set_level)) |
61
|
|
|
|
|
|
|
? $self->write($level, $self->output($self->input(@args))) |
62
|
|
|
|
|
|
|
: $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub debug { |
66
|
3
|
|
|
3
|
1
|
12
|
my ($self, @args) = @_; |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
14
|
return $self->commit('debug', @args); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub error { |
72
|
6
|
|
|
6
|
1
|
28
|
my ($self, @args) = @_; |
73
|
|
|
|
|
|
|
|
74
|
6
|
|
|
|
|
22
|
return $self->commit('error', @args); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub fatal { |
78
|
3
|
|
|
3
|
1
|
12
|
my ($self, @args) = @_; |
79
|
|
|
|
|
|
|
|
80
|
3
|
|
|
|
|
11
|
return $self->commit('fatal', @args); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub info { |
84
|
7
|
|
|
7
|
1
|
27
|
my ($self, @args) = @_; |
85
|
|
|
|
|
|
|
|
86
|
7
|
|
|
|
|
30
|
return $self->commit('info', @args); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub input { |
90
|
21
|
|
|
21
|
1
|
67
|
my ($self, @args) = @_; |
91
|
|
|
|
|
|
|
|
92
|
21
|
|
|
|
|
68
|
return (@args); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub level_code { |
96
|
52
|
|
|
52
|
0
|
106
|
my ($self, $data) = @_; |
97
|
|
|
|
|
|
|
|
98
|
52
|
50
|
|
|
|
151
|
$data = $data ? lc $data : $self->level; |
99
|
|
|
|
|
|
|
|
100
|
52
|
|
66
|
|
|
235
|
return $$NAME{$data} || ($$CODE{$data} && $$NAME{$$CODE{$data}}); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub level_name { |
104
|
26
|
|
|
26
|
0
|
55
|
my ($self, $data) = @_; |
105
|
|
|
|
|
|
|
|
106
|
26
|
50
|
|
|
|
69
|
$data = $data ? lc $data : $self->level; |
107
|
|
|
|
|
|
|
|
108
|
26
|
|
66
|
|
|
143
|
return $$CODE{$data} || ($$NAME{$data} && $$CODE{$$NAME{$data}}); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub output { |
112
|
21
|
|
|
21
|
1
|
65
|
my ($self, @args) = @_; |
113
|
|
|
|
|
|
|
|
114
|
21
|
|
|
|
|
62
|
return (join $self->separator, map $self->string($_), @args); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub string { |
118
|
40
|
|
|
40
|
1
|
103
|
my ($self, $data) = @_; |
119
|
|
|
|
|
|
|
|
120
|
40
|
|
|
|
|
174
|
require Scalar::Util; |
121
|
|
|
|
|
|
|
|
122
|
40
|
100
|
|
|
|
103
|
if (!defined $data) { |
123
|
1
|
|
|
|
|
9
|
return ''; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
39
|
|
|
|
|
104
|
my $blessed = Scalar::Util::blessed($data); |
127
|
39
|
|
33
|
|
|
114
|
my $isvenus = $blessed && $data->isa('Venus::Core') && $data->can('does'); |
128
|
|
|
|
|
|
|
|
129
|
39
|
100
|
100
|
|
|
146
|
if (!$blessed && !ref $data) { |
130
|
37
|
|
|
|
|
195
|
return $data; |
131
|
|
|
|
|
|
|
} |
132
|
2
|
50
|
66
|
|
|
12
|
if ($blessed && ref($data) eq 'Regexp') { |
133
|
0
|
|
|
|
|
0
|
return "$data"; |
134
|
|
|
|
|
|
|
} |
135
|
2
|
50
|
33
|
|
|
9
|
if ($isvenus && $data->does('Venus::Role::Explainable')) { |
136
|
0
|
|
|
0
|
|
0
|
return $self->dump(sub{$data->explain}); |
|
0
|
|
|
|
|
0
|
|
137
|
|
|
|
|
|
|
} |
138
|
2
|
50
|
33
|
|
|
7
|
if ($isvenus && $data->does('Venus::Role::Valuable')) { |
139
|
0
|
|
|
0
|
|
0
|
return $self->dump(sub{$data->value}); |
|
0
|
|
|
|
|
0
|
|
140
|
|
|
|
|
|
|
} |
141
|
2
|
50
|
33
|
|
|
8
|
if ($isvenus && $data->does('Venus::Role::Dumpable')) { |
142
|
0
|
|
|
|
|
0
|
return $data->dump; |
143
|
|
|
|
|
|
|
} |
144
|
2
|
50
|
66
|
|
|
12
|
if ($blessed && overload::Method($data, '""')) { |
145
|
0
|
|
|
|
|
0
|
return "$data"; |
146
|
|
|
|
|
|
|
} |
147
|
2
|
50
|
66
|
|
|
77
|
if ($blessed && $data->can('as_string')) { |
148
|
0
|
|
|
|
|
0
|
return $data->as_string; |
149
|
|
|
|
|
|
|
} |
150
|
2
|
50
|
66
|
|
|
15
|
if ($blessed && $data->can('to_string')) { |
151
|
0
|
|
|
|
|
0
|
return $data->to_string; |
152
|
|
|
|
|
|
|
} |
153
|
2
|
50
|
66
|
|
|
13
|
if ($blessed && $data->isa('Venus::Kind')) { |
154
|
0
|
|
|
|
|
0
|
return $data->stringified; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
else { |
157
|
2
|
|
|
2
|
|
21
|
return $self->dump(sub{$data}); |
|
2
|
|
|
|
|
19
|
|
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub trace { |
162
|
4
|
|
|
4
|
1
|
22
|
my ($self, @args) = @_; |
163
|
|
|
|
|
|
|
|
164
|
4
|
|
|
|
|
17
|
return $self->commit('trace', @args); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub warn { |
168
|
3
|
|
|
3
|
1
|
12
|
my ($self, @args) = @_; |
169
|
|
|
|
|
|
|
|
170
|
3
|
|
|
|
|
11
|
return $self->commit('warn', @args); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub write { |
174
|
22
|
|
|
22
|
1
|
74
|
my ($self, $level, @args) = @_; |
175
|
|
|
|
|
|
|
|
176
|
22
|
|
|
|
|
62
|
$self->handler->($level, @args); |
177
|
|
|
|
|
|
|
|
178
|
22
|
|
|
|
|
222
|
return $self; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
1; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 NAME |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Venus::Log - Log Class |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 ABSTRACT |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Log Class for Perl 5 |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 SYNOPSIS |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
package main; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
use Venus::Log; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
my $log = Venus::Log->new; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# $log->trace(time, 'Something failed!'); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# $log->error(time, 'Something failed!'); |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 DESCRIPTION |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This package provides methods for logging information using various log levels. |
218
|
|
|
|
|
|
|
The default log level is L. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This package has the following attributes: |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 handler |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
handler(CodeRef $code) (CodeRef) |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
The handler attribute holds the callback that handles logging. The handler is |
233
|
|
|
|
|
|
|
passed the log level and the log messages. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
I> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=over 4 |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item handler example 1 |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
# given: synopsis |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
package main; |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
my $handler = $log->handler; |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
my $events = []; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
$handler = $log->handler(sub{shift; push @$events, [@_]}); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=back |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=cut |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 level |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
level(Str $name) (Str) |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
The level attribute holds the current log level. Valid log levels are C, |
260
|
|
|
|
|
|
|
C, C, C, C and C, and will emit log messages |
261
|
|
|
|
|
|
|
in that order. Invalid log levels effectively disable logging. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
I> |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=over 4 |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item level example 1 |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# given: synopsis |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
package main; |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
my $level = $log->level; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
# "trace" |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
$level = $log->level('fatal'); |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
# "fatal" |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=back |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=cut |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head2 separator |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
separator(Any $data) (Any) |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
The separator attribute holds the value used to join multiple log message arguments. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
I> |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=over 4 |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=item separator example 1 |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
# given: synopsis |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
package main; |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
my $separator = $log->separator; |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# "" |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
$separator = $log->separator("\n"); |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
# "\n" |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=back |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=cut |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 INHERITS |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
This package inherits behaviors from: |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
L |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=cut |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=head1 INTEGRATES |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
This package integrates behaviors from: |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
L |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=cut |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=head1 METHODS |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
This package provides the following methods: |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=cut |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
=head2 debug |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
debug(Str @data) (Log) |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
The debug method logs C information and returns the invocant. |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
I> |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=over 4 |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=item debug example 1 |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
# given: synopsis |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
package main; |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
# $log = $log->debug(time, 'Something failed!'); |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
=back |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=over 4 |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=item debug example 2 |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
# given: synopsis |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
package main; |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# $log->level('info'); |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
# $log = $log->debug(time, 'Something failed!'); |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
# noop |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=back |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=cut |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=head2 error |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
error(Str @data) (Log) |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
The error method logs C information and returns the invocant. |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
I> |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=over 4 |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=item error example 1 |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
# given: synopsis |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
package main; |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
# $log = $log->error(time, 'Something failed!'); |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=back |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
=over 4 |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=item error example 2 |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
# given: synopsis |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
package main; |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
# $log->level('fatal'); |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
# $log = $log->error(time, 'Something failed!'); |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
# noop |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=back |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=cut |
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
=head2 fatal |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
fatal(Str @data) (Log) |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
The fatal method logs C information and returns the invocant. |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
I> |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
=over 4 |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=item fatal example 1 |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
# given: synopsis |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
package main; |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
# $log = $log->fatal(time, 'Something failed!'); |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=back |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=over 4 |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=item fatal example 2 |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
# given: synopsis |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
package main; |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
# $log->level('unknown'); |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
# $log = $log->fatal(time, 'Something failed!'); |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
# noop |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=back |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=cut |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 info |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
info(Str @data) (Log) |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
The info method logs C information and returns the invocant. |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
I> |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=over 4 |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=item info example 1 |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
# given: synopsis |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
package main; |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
# $log = $log->info(time, 'Something failed!'); |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=back |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=over 4 |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=item info example 2 |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
# given: synopsis |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
package main; |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
# $log->level('warn'); |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
# $log = $log->info(time, 'Something failed!'); |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
# noop |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=back |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=cut |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
=head2 input |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
input(Str @data) (Str) |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
The input method returns the arguments provided to the log level methods, to |
500
|
|
|
|
|
|
|
the L, and can be overridden by subclasses. |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
I> |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=over 4 |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
=item input example 1 |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
# given: synopsis |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
package main; |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
my @input = $log->input(1, 'Something failed!'); |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
# (1, 'Something failed!') |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=back |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
=cut |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=head2 output |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
output(Str @data) (Str) |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
The output method returns the arguments returned by the L method, to |
525
|
|
|
|
|
|
|
the log handler, and can be overridden by subclasses. |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
I> |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=over 4 |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=item output example 1 |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
# given: synopsis |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
package main; |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
my $output = $log->output(time, 'Something failed!'); |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=back |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=cut |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
=head2 string |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
string(Any $data) (Str) |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
The string method returns a stringified representation of any argument provided |
550
|
|
|
|
|
|
|
and is used by the L method. |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
I> |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
=over 4 |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=item string example 1 |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
# given: synopsis |
559
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
package main; |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
my $string = $log->string; |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
# "" |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=back |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
=over 4 |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
=item string example 2 |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
# given: synopsis |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
package main; |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
my $string = $log->string('Something failed!'); |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
# "Something failed!" |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
=back |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=over 4 |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
=item string example 3 |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
# given: synopsis |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
package main; |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
my $string = $log->string([1,2,3]); |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
# [1,2,3] |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=back |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
=over 4 |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=item string example 4 |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# given: synopsis |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
package main; |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
my $string = $log->string(bless({})); |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
# "bless({}, 'main')" |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
=back |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=cut |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head2 trace |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
trace(Str @data) (Log) |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
The trace method logs C information and returns the invocant. |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
I> |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=over 4 |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=item trace example 1 |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
# given: synopsis |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
package main; |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
# $log = $log->trace(time, 'Something failed!'); |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=back |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
=over 4 |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=item trace example 2 |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
# given: synopsis |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
package main; |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
# $log->level('debug'); |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
# $log = $log->trace(time, 'Something failed!'); |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
# noop |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=back |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=cut |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=head2 warn |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
warn(Str @data) (Log) |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
The warn method logs C information and returns the invocant. |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
I> |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
=over 4 |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
=item warn example 1 |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
# given: synopsis |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
package main; |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
# $log = $log->warn(time, 'Something failed!'); |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
# "0000000000 Something failed!" |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=back |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=over 4 |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=item warn example 2 |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
# given: synopsis |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
package main; |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
# $log->level('error'); |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# $log = $log->warn(time, 'Something failed!'); |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
# noop |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=back |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=cut |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=head2 write |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
write(Str $level, Any @data) (Log) |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
The write method invokes the log handler, i.e. L, and returns the invocant. |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
I> |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=over 4 |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=item write example 1 |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
# given: synopsis |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
package main; |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
# $log = $log->write('info', time, 'Something failed!'); |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
# bless(..., "Venus::Log") |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
=back |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=cut |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
=head1 AUTHORS |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
Awncorp, C |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
=cut |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=head1 LICENSE |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
727
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
=cut |