line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::ACME::Logger; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2954
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
151
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
156
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
31
|
use Log::Any::Adapter; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
28
|
|
7
|
5
|
|
|
5
|
|
129
|
use base qw/Log::Any::Adapter::Base/; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
2351
|
|
8
|
5
|
|
|
5
|
|
5676
|
use Time::HiRes qw( gettimeofday ); |
|
5
|
|
|
|
|
6921
|
|
|
5
|
|
|
|
|
21
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %LOG_LEVELS = ( |
13
|
|
|
|
|
|
|
emergency => 0, |
14
|
|
|
|
|
|
|
alert => 1, |
15
|
|
|
|
|
|
|
critical => 2, |
16
|
|
|
|
|
|
|
fatal => 2, |
17
|
|
|
|
|
|
|
crit => 2, |
18
|
|
|
|
|
|
|
err => 2, |
19
|
|
|
|
|
|
|
error => 3, |
20
|
|
|
|
|
|
|
warn => 4, |
21
|
|
|
|
|
|
|
warning => 4, |
22
|
|
|
|
|
|
|
notice => 5, |
23
|
|
|
|
|
|
|
inform => 6, |
24
|
|
|
|
|
|
|
info => 6, |
25
|
|
|
|
|
|
|
debug => 7, |
26
|
|
|
|
|
|
|
trace => 8, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub init { |
30
|
6
|
|
|
6
|
0
|
701
|
my ($self) = @_; |
31
|
6
|
50
|
|
|
|
35
|
if ( exists $self->{log_level} ) { |
32
|
|
|
|
|
|
|
$self->{log_level} = $LOG_LEVELS{lc($self->{log_level})} |
33
|
6
|
50
|
|
|
|
49
|
unless $self->{log_level} =~ /^\d+$/; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
0
|
$self->{log_level} = $LOG_LEVELS{trace}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
foreach my $method (keys %LOG_LEVELS) { |
41
|
5
|
|
|
5
|
|
2062
|
no strict 'refs'; |
|
5
|
|
|
|
|
37
|
|
|
5
|
|
|
|
|
931
|
|
42
|
|
|
|
|
|
|
my $method_level = $LOG_LEVELS{$method}; |
43
|
|
|
|
|
|
|
*{$method} = sub { |
44
|
27
|
|
|
27
|
|
1265
|
my ( $self, $text ) = @_; |
45
|
27
|
50
|
|
|
|
126
|
return if $method_level > $self->{log_level}; |
46
|
27
|
|
|
|
|
144
|
my ( $sec, $usec ) = gettimeofday(); |
47
|
27
|
|
|
|
|
1520
|
printf STDOUT "# %d.%06d %s\n", $sec, $usec, $text; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
my $detection_method = 'is_' . $method; |
50
|
|
|
|
|
|
|
*{$detection_method} = sub { |
51
|
40
|
|
|
40
|
|
752
|
return !!( $method_level <= $_[0]->{log_level} ); |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |