line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::MirrorMerger::Logger; |
2
|
2
|
|
|
2
|
|
206240
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
45
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
53
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
373
|
use Class::Accessor::Lite ro => [qw/level/], new => 1; |
|
2
|
|
|
|
|
1061
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
631
|
use Data::Dumper (); |
|
2
|
|
|
|
|
5603
|
|
|
2
|
|
|
|
|
39
|
|
8
|
2
|
|
|
2
|
|
758
|
use Time::Moment; |
|
2
|
|
|
|
|
2259
|
|
|
2
|
|
|
|
|
611
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %LEVEL_MAP = ( |
11
|
|
|
|
|
|
|
error => 1000, |
12
|
|
|
|
|
|
|
warn => 500, |
13
|
|
|
|
|
|
|
info => 100, |
14
|
|
|
|
|
|
|
debug => 10, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
0
|
sub write_log { require Carp; Carp::croak('abstruct method') } |
|
0
|
|
|
|
|
0
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub format_log { |
20
|
6
|
|
|
6
|
0
|
22
|
my ($self, $now, $level, $msg, $attr) = @_; |
21
|
6
|
50
|
|
|
|
14
|
unless (defined $attr) { |
22
|
6
|
|
|
|
|
75
|
return sprintf '%s [%s] %s', $now->to_string(), uc $level, $msg; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
my $attr_str = do { |
26
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Terse = 1; |
27
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Indent = 0; |
28
|
0
|
|
|
|
|
0
|
local $Data::Dumper::Sortkeys = 1; |
29
|
0
|
|
|
|
|
0
|
Data::Dumper::Dumper($attr); |
30
|
|
|
|
|
|
|
}; |
31
|
0
|
|
|
|
|
0
|
return sprintf '%s [%s] %s (%s)', $now->to_string(), uc $level, $msg, $attr_str; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _log { |
35
|
18
|
|
|
18
|
|
38
|
my ($self, $level, $msg, $attr) = @_; |
36
|
18
|
100
|
|
|
|
43
|
return if $LEVEL_MAP{$level} < $LEVEL_MAP{$self->level}; |
37
|
|
|
|
|
|
|
|
38
|
6
|
|
|
|
|
62
|
my $now = Time::Moment->now_utc(); |
39
|
6
|
|
|
|
|
16
|
my $payload = $self->format_log($now, $level, $msg, $attr); |
40
|
6
|
|
|
|
|
20
|
$self->write_log($payload); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub error { |
44
|
0
|
|
|
0
|
0
|
0
|
my ($self, $msg, $attr) = @_; |
45
|
0
|
|
|
|
|
0
|
$self->_log(error => $msg, $attr); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub warn { |
49
|
0
|
|
|
0
|
0
|
0
|
my ($self, $msg, $attr) = @_; |
50
|
0
|
|
|
|
|
0
|
$self->_log(warn => $msg, $attr); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub info { |
54
|
6
|
|
|
6
|
0
|
59
|
my ($self, $msg, $attr) = @_; |
55
|
6
|
|
|
|
|
16
|
$self->_log(info => $msg, $attr); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub debug { |
59
|
12
|
|
|
12
|
0
|
1084
|
my ($self, $msg, $attr) = @_; |
60
|
12
|
|
|
|
|
26
|
$self->_log(debug => $msg, $attr); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |