line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Plugin::Log4perl; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2017-07-12'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
740
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
39
|
|
7
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
8
|
use Log::ger (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1253
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub get_hooks { |
12
|
3
|
|
|
3
|
0
|
139
|
my %conf = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
return { |
15
|
|
|
|
|
|
|
create_formatter => [ |
16
|
|
|
|
|
|
|
__PACKAGE__, 50, |
17
|
|
|
|
|
|
|
sub { |
18
|
|
|
|
|
|
|
my $formatter = sub { |
19
|
|
|
|
|
|
|
return |
20
|
2
|
100
|
|
|
|
189
|
join("", map { ref $_ eq 'CODE' ? ($_->()) : ($_) } @_); |
|
5
|
|
|
|
|
21
|
|
21
|
7
|
|
|
7
|
|
1715
|
}; |
22
|
7
|
|
|
|
|
34
|
return [$formatter, 0, 'log4perl']; |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
], |
25
|
|
|
|
|
|
|
create_routine_names => [ |
26
|
|
|
|
|
|
|
__PACKAGE__, 50, |
27
|
|
|
|
|
|
|
sub { |
28
|
7
|
|
|
7
|
|
750
|
my %args = @_; |
29
|
|
|
|
|
|
|
|
30
|
7
|
|
|
|
|
37
|
my $levels = [keys %Log::ger::Levels]; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return [{ |
33
|
|
|
|
|
|
|
log_subs => [ |
34
|
42
|
|
|
|
|
173
|
(map { [uc($_), $_, "log4perl"] } @$levels), |
35
|
|
|
|
|
|
|
["LOGDIE" , "fatal", "log4perl"], |
36
|
|
|
|
|
|
|
["LOGWARN" , "warn" , "log4perl"], |
37
|
|
|
|
|
|
|
["LOGCARP" , "warn" , "log4perl"], |
38
|
|
|
|
|
|
|
["LOGCLUCK" , "warn" , "log4perl"], |
39
|
|
|
|
|
|
|
["LOGCROAK" , "fatal", "log4perl"], |
40
|
|
|
|
|
|
|
["LOGCONFESS", "fatal", "log4perl"], |
41
|
|
|
|
|
|
|
], |
42
|
|
|
|
|
|
|
is_subs => [], |
43
|
|
|
|
|
|
|
log_methods => [ |
44
|
42
|
|
|
|
|
170
|
(map { ["$_", $_, "log4perl"] } @$levels), |
45
|
|
|
|
|
|
|
["logdie" , "fatal", "log4perl"], |
46
|
|
|
|
|
|
|
["logwarn" , "warn" , "log4perl"], |
47
|
|
|
|
|
|
|
["logcarp" , "warn" , "log4perl"], |
48
|
|
|
|
|
|
|
["logcluck" , "warn" , "log4perl"], |
49
|
|
|
|
|
|
|
["logcroak" , "fatal", "log4perl"], |
50
|
|
|
|
|
|
|
["logconfess", "fatal", "log4perl"], |
51
|
|
|
|
|
|
|
["error_die" , "error", "log4perl"], |
52
|
|
|
|
|
|
|
["error_warn", "error", "log4perl"], |
53
|
|
|
|
|
|
|
], |
54
|
|
|
|
|
|
|
logml_methods => [ |
55
|
|
|
|
|
|
|
["log", undef, "log4perl"], |
56
|
|
|
|
|
|
|
], |
57
|
|
|
|
|
|
|
is_methods => [ |
58
|
7
|
|
|
|
|
25
|
map { ["is_$_", $_] } @$levels, |
|
42
|
|
|
|
|
219
|
|
59
|
|
|
|
|
|
|
], |
60
|
|
|
|
|
|
|
}, 1]; |
61
|
|
|
|
|
|
|
}], |
62
|
|
|
|
|
|
|
before_install_routines => [ |
63
|
|
|
|
|
|
|
__PACKAGE__, 50, |
64
|
|
|
|
|
|
|
sub { |
65
|
7
|
|
|
7
|
|
11085
|
my %args = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# wrap the logdie, et al |
68
|
7
|
|
|
|
|
23
|
for my $r (@{ $args{routines} }) { |
|
7
|
|
|
|
|
23
|
|
69
|
93
|
|
|
|
|
250
|
my ($code, $name, $numlevel, $type) = @$r; |
70
|
93
|
100
|
|
|
|
694
|
if ($name =~ /\A(logdie|error_die)\z/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
71
|
2
|
|
|
0
|
|
41
|
$r->[0] = sub { $code->(@_); shift; die $args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
72
|
|
|
|
|
|
|
} elsif ($name eq 'LOGDIE') { |
73
|
6
|
|
|
0
|
|
50
|
$r->[0] = sub { $code->(@_); die $args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
74
|
|
|
|
|
|
|
} elsif ($name =~ /\A(logwarn|error_warn)\z/) { |
75
|
2
|
|
|
0
|
|
13
|
$r->[0] = sub { $code->(@_); shift; warn $args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
76
|
|
|
|
|
|
|
} elsif ($name eq 'LOGWARN') { |
77
|
6
|
|
|
0
|
|
39
|
$r->[0] = sub { $code->(@_); warn $args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
78
|
|
|
|
|
|
|
} elsif ($name eq 'logcarp') { |
79
|
1
|
|
|
|
|
10
|
require Carp; |
80
|
1
|
|
|
0
|
|
5
|
$r->[0] = sub { $code->(@_); shift; Carp::carp($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCARP') { |
82
|
6
|
|
|
|
|
53
|
require Carp; |
83
|
6
|
|
|
0
|
|
43
|
$r->[0] = sub { $code->(@_); Carp::carp($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
84
|
|
|
|
|
|
|
} elsif ($name eq 'logcluck') { |
85
|
1
|
|
|
|
|
4
|
require Carp; |
86
|
1
|
|
|
0
|
|
4
|
$r->[0] = sub { $code->(@_); shift; Carp::cluck($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
87
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCLUCK') { |
88
|
6
|
|
|
|
|
30
|
require Carp; |
89
|
6
|
|
|
0
|
|
33
|
$r->[0] = sub { $code->(@_); Carp::cluck($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
90
|
|
|
|
|
|
|
} elsif ($name eq 'logcroak') { |
91
|
1
|
|
|
|
|
3
|
require Carp; |
92
|
1
|
|
|
0
|
|
6
|
$r->[0] = sub { $code->(@_); shift; Carp::croak($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
93
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCROAK') { |
94
|
6
|
|
|
|
|
32
|
require Carp; |
95
|
6
|
|
|
0
|
|
39
|
$r->[0] = sub { $code->(@_); Carp::croak($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
96
|
|
|
|
|
|
|
} elsif ($name eq 'logconfess') { |
97
|
1
|
|
|
|
|
4
|
require Carp; |
98
|
1
|
|
|
0
|
|
4
|
$r->[0] = sub { $code->(@_); shift; Carp::confess($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
99
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCONFESS') { |
100
|
6
|
|
|
|
|
30
|
require Carp; |
101
|
6
|
|
|
0
|
|
58
|
$r->[0] = sub { $code->(@_); Carp::confess($args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
}, |
105
|
3
|
|
|
|
|
56
|
], |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
# ABSTRACT: Plugin to mimic Log::Log4perl |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |