line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Plugin::Log4perl; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-03-11'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Log-ger-Like-Log4perl'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
464
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use Log::ger (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
899
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub meta { +{ |
14
|
3
|
|
|
3
|
0
|
108
|
v => 2, |
15
|
|
|
|
|
|
|
} } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_hooks { |
18
|
3
|
|
|
3
|
0
|
34
|
my %plugin_conf = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return { |
21
|
|
|
|
|
|
|
create_formatter => [ |
22
|
|
|
|
|
|
|
__PACKAGE__, 50, |
23
|
|
|
|
|
|
|
sub { |
24
|
|
|
|
|
|
|
my $formatter = sub { |
25
|
|
|
|
|
|
|
return |
26
|
1
|
100
|
|
|
|
418
|
join("", map { ref $_ eq 'CODE' ? ($_->()) : ($_) } @_); |
|
3
|
|
|
|
|
10
|
|
27
|
29
|
|
|
29
|
|
3371
|
}; |
28
|
29
|
|
|
|
|
67
|
return [$formatter, 0, 'log4perl']; |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
], |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
create_routine_names => [ |
33
|
|
|
|
|
|
|
__PACKAGE__, 50, |
34
|
|
|
|
|
|
|
sub { |
35
|
29
|
|
|
29
|
|
1280
|
my %hook_args = @_; |
36
|
|
|
|
|
|
|
|
37
|
29
|
|
|
|
|
88
|
my $levels = [keys %Log::ger::Levels]; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return [{ |
40
|
|
|
|
|
|
|
logger_subs => [ |
41
|
174
|
|
|
|
|
405
|
(map { [uc($_), $_, "log4perl"] } @$levels), |
42
|
|
|
|
|
|
|
["LOGDIE" , "fatal", "log4perl"], |
43
|
|
|
|
|
|
|
["LOGWARN" , "warn" , "log4perl"], |
44
|
|
|
|
|
|
|
["LOGCARP" , "warn" , "log4perl"], |
45
|
|
|
|
|
|
|
["LOGCLUCK" , "warn" , "log4perl"], |
46
|
|
|
|
|
|
|
["LOGCROAK" , "fatal", "log4perl"], |
47
|
|
|
|
|
|
|
["LOGCONFESS", "fatal", "log4perl"], |
48
|
|
|
|
|
|
|
], |
49
|
|
|
|
|
|
|
level_checker_subs => [], |
50
|
|
|
|
|
|
|
logger_methods => [ |
51
|
174
|
|
|
|
|
422
|
(map { ["$_", $_, "log4perl"] } @$levels), |
52
|
|
|
|
|
|
|
["logdie" , "fatal", "log4perl"], |
53
|
|
|
|
|
|
|
["logwarn" , "warn" , "log4perl"], |
54
|
|
|
|
|
|
|
["logcarp" , "warn" , "log4perl"], |
55
|
|
|
|
|
|
|
["logcluck" , "warn" , "log4perl"], |
56
|
|
|
|
|
|
|
["logcroak" , "fatal", "log4perl"], |
57
|
|
|
|
|
|
|
["logconfess", "fatal", "log4perl"], |
58
|
|
|
|
|
|
|
["error_die" , "error", "log4perl"], |
59
|
|
|
|
|
|
|
["error_warn", "error", "log4perl"], |
60
|
|
|
|
|
|
|
], |
61
|
|
|
|
|
|
|
level_checker_methods => [ |
62
|
29
|
|
|
|
|
58
|
map { ["is_$_", $_] } @$levels, |
|
174
|
|
|
|
|
426
|
|
63
|
|
|
|
|
|
|
], |
64
|
|
|
|
|
|
|
}, 0]; |
65
|
|
|
|
|
|
|
}], |
66
|
|
|
|
|
|
|
before_install_routines => [ |
67
|
|
|
|
|
|
|
__PACKAGE__, 50, |
68
|
|
|
|
|
|
|
sub { |
69
|
29
|
|
|
29
|
|
37086
|
my %hook_args = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# wrap the logdie, et al |
72
|
29
|
|
|
|
|
43
|
for my $r (@{ $hook_args{routines} }) { |
|
29
|
|
|
|
|
60
|
|
73
|
1427
|
|
|
|
|
2247
|
my ($code, $name, $numlevel, $type) = @$r; |
74
|
1427
|
100
|
|
|
|
5588
|
if ($name =~ /\A(logdie|error_die)\z/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
75
|
44
|
|
|
0
|
|
195
|
$r->[0] = sub { $code->(@_); shift; die $hook_args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
76
|
|
|
|
|
|
|
} elsif ($name eq 'LOGDIE') { |
77
|
53
|
|
|
0
|
|
241
|
$r->[0] = sub { $code->(@_); die $hook_args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
78
|
|
|
|
|
|
|
} elsif ($name =~ /\A(logwarn|error_warn)\z/) { |
79
|
44
|
|
|
0
|
|
157
|
$r->[0] = sub { $code->(@_); shift; warn $hook_args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
80
|
|
|
|
|
|
|
} elsif ($name eq 'LOGWARN') { |
81
|
53
|
|
|
0
|
|
201
|
$r->[0] = sub { $code->(@_); warn $hook_args{formatters}{log4perl}(@_) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
82
|
|
|
|
|
|
|
} elsif ($name eq 'logcarp') { |
83
|
22
|
|
|
|
|
77
|
require Carp; |
84
|
22
|
|
|
0
|
|
98
|
$r->[0] = sub { $code->(@_); shift; Carp::carp($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCARP') { |
86
|
53
|
|
|
|
|
203
|
require Carp; |
87
|
53
|
|
|
0
|
|
209
|
$r->[0] = sub { $code->(@_); Carp::carp($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
88
|
|
|
|
|
|
|
} elsif ($name eq 'logcluck') { |
89
|
22
|
|
|
|
|
67
|
require Carp; |
90
|
22
|
|
|
0
|
|
103
|
$r->[0] = sub { $code->(@_); shift; Carp::cluck($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCLUCK') { |
92
|
53
|
|
|
|
|
146
|
require Carp; |
93
|
53
|
|
|
0
|
|
222
|
$r->[0] = sub { $code->(@_); Carp::cluck($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
94
|
|
|
|
|
|
|
} elsif ($name eq 'logcroak') { |
95
|
22
|
|
|
|
|
72
|
require Carp; |
96
|
22
|
|
|
0
|
|
96
|
$r->[0] = sub { $code->(@_); shift; Carp::croak($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
97
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCROAK') { |
98
|
53
|
|
|
|
|
148
|
require Carp; |
99
|
53
|
|
|
0
|
|
214
|
$r->[0] = sub { $code->(@_); Carp::croak($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
100
|
|
|
|
|
|
|
} elsif ($name eq 'logconfess') { |
101
|
22
|
|
|
|
|
64
|
require Carp; |
102
|
22
|
|
|
0
|
|
66
|
$r->[0] = sub { $code->(@_); shift; Carp::confess($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
103
|
|
|
|
|
|
|
} elsif ($name eq 'LOGCONFESS') { |
104
|
53
|
|
|
|
|
157
|
require Carp; |
105
|
53
|
|
|
0
|
|
208
|
$r->[0] = sub { $code->(@_); Carp::confess($hook_args{formatters}{log4perl}(@_)) }; |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
29
|
|
|
|
|
82
|
[]; |
109
|
|
|
|
|
|
|
}, |
110
|
3
|
|
|
|
|
63
|
], |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
# ABSTRACT: Plugin to mimic Log::Log4perl (log.+()) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |