line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kelp::Module::Logger::Log4perl; |
2
|
|
|
|
|
|
|
our $VERSION = "0.002"; |
3
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
4
|
1
|
|
|
1
|
|
129858
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Kelp::Base 'Kelp::Module::Logger'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
14005
|
use Log::Log4perl; |
|
1
|
|
|
|
|
37978
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
46
|
use Log::Log4perl::Level; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
10
|
1
|
|
|
1
|
|
103
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
87
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
attr 'category' => ''; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use constant ({ |
15
|
1
|
|
|
|
|
313
|
NOTICE => $INFO + 1, |
16
|
|
|
|
|
|
|
CRITICAL => $ERROR + 1, |
17
|
|
|
|
|
|
|
ALERT => $FATAL + 1, |
18
|
|
|
|
|
|
|
EMERGENCY => $OFF - 1 |
19
|
1
|
|
|
1
|
|
4
|
}); |
|
1
|
|
|
|
|
1
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _logger { |
22
|
4
|
|
|
4
|
|
28233
|
my ( $self, %args ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
17
|
Log::Log4perl::Level::add_priority('NOTICE', NOTICE, 2, 2); |
25
|
4
|
|
|
|
|
48
|
Log::Log4perl::Level::add_priority('CRITICAL', CRITICAL, 0, 5); |
26
|
4
|
|
|
|
|
30
|
Log::Log4perl::Level::add_priority('ALERT', ALERT, -1, 6); |
27
|
4
|
|
|
|
|
31
|
Log::Log4perl::Level::add_priority('EMERGENCY', EMERGENCY, -1, 7); |
28
|
4
|
|
|
|
|
50
|
Log::Log4perl->init($args{conf}); |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
100
|
|
|
9279
|
return Log::Log4perl->get_logger($args{category} || ''); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Override because Log4perl has own configurable layouts. |
34
|
|
|
|
|
|
|
sub message { |
35
|
32
|
|
|
32
|
0
|
72774
|
my ($self, $level, @messages) = @_; |
36
|
|
|
|
|
|
|
|
37
|
32
|
|
|
|
|
155
|
my %LEVELS_map = ( |
38
|
|
|
|
|
|
|
trace => $TRACE, |
39
|
|
|
|
|
|
|
debug => $DEBUG, |
40
|
|
|
|
|
|
|
info => $INFO, |
41
|
|
|
|
|
|
|
warn => $WARN, |
42
|
|
|
|
|
|
|
error => $ERROR, |
43
|
|
|
|
|
|
|
fatal => $FATAL, |
44
|
|
|
|
|
|
|
always => $OFF, |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
notice => NOTICE, |
47
|
|
|
|
|
|
|
critical => CRITICAL, |
48
|
|
|
|
|
|
|
alert => ALERT, |
49
|
|
|
|
|
|
|
emergency => EMERGENCY, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
32
|
|
|
|
|
61
|
for (@messages) { |
53
|
32
|
50
|
|
|
|
55
|
my $message = ref($_) ? Dumper($_) : $_; |
54
|
32
|
|
|
|
|
92
|
$self->{logger}->log( $LEVELS_map{$level}, $message ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |