line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Plugin::WithCarp; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-03-07'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Log-ger-Plugin-WithWarn'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
69374
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
28
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
12
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
12
|
1
|
|
|
1
|
|
4
|
use Log::ger (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1038
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub get_hooks { |
15
|
1
|
|
|
1
|
0
|
11
|
my %plugin_conf = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return { |
18
|
|
|
|
|
|
|
create_routine_names => [ |
19
|
|
|
|
|
|
|
__PACKAGE__, # key |
20
|
|
|
|
|
|
|
50, # priority |
21
|
|
|
|
|
|
|
sub { # hook |
22
|
2
|
|
|
2
|
|
522
|
my %hook_args = @_; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
4
|
my $levels = \%Log::ger::Levels; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return [{ |
27
|
|
|
|
|
|
|
logger_subs => [ |
28
|
2
|
|
|
|
|
13
|
(map { (["log_${_}_carp", $_, "default"], ["log_${_}_cluck", $_, "default"]) } |
29
|
12
|
|
|
|
|
21
|
grep {$levels->{$_} == 30} keys %$levels), |
30
|
4
|
|
|
|
|
17
|
(map { (["log_${_}_croak", $_, "default"], ["log_${_}_confess", $_, "default"]) } |
31
|
12
|
50
|
|
|
|
37
|
grep {$levels->{$_} > 0 && $levels->{$_} <= 20} keys %$levels), |
32
|
|
|
|
|
|
|
], |
33
|
|
|
|
|
|
|
level_checker_subs => [], |
34
|
|
|
|
|
|
|
logger_methods => [ |
35
|
2
|
|
|
|
|
10
|
(map { (["${_}_carp", $_, "default"], ["${_}_cluck", $_, "default"]) } |
36
|
12
|
|
|
|
|
18
|
grep {$levels->{$_} == 30} keys %$levels), |
37
|
4
|
|
|
|
|
21
|
(map { (["${_}_croak", $_, "default"], ["${_}_confess", $_, "default"]) } |
38
|
2
|
50
|
|
|
|
8
|
grep {$levels->{$_} > 0 && $levels->{$_} <= 20} keys %$levels), |
|
12
|
|
|
|
|
34
|
|
39
|
|
|
|
|
|
|
], |
40
|
|
|
|
|
|
|
level_checker_methods => [ |
41
|
|
|
|
|
|
|
], |
42
|
|
|
|
|
|
|
}, 0]; |
43
|
|
|
|
|
|
|
}], |
44
|
|
|
|
|
|
|
before_install_routines => [ |
45
|
|
|
|
|
|
|
__PACKAGE__, # key |
46
|
|
|
|
|
|
|
50, # priority |
47
|
|
|
|
|
|
|
sub { # hook |
48
|
2
|
|
|
2
|
|
2193
|
my %hook_args = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# wrap the logger |
51
|
2
|
|
|
|
|
4
|
for my $r (@{ $hook_args{routines} }) { |
|
2
|
|
|
|
|
6
|
|
52
|
36
|
|
|
|
|
70
|
my ($code, $name, $numlevel, $type) = @$r; |
53
|
36
|
100
|
100
|
1
|
|
335
|
if ($type =~ /^log(ger)?_sub/ && $name =~ /\Alog_\w+_carp\z/ ) { $r->[0] = sub { $code->(@_); Carp::carp ($hook_args{formatters}{default}(@_)."\n") } } |
|
1
|
100
|
100
|
|
|
4
|
|
|
1
|
100
|
100
|
|
|
315
|
|
|
1
|
100
|
100
|
|
|
6
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
54
|
1
|
|
|
1
|
|
7
|
elsif ($type =~ /^log(ger)?_method/ && $name =~ /\A\w+_carp\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::carp ($hook_args{formatters}{default}(@_)."\n") } } |
|
1
|
|
|
|
|
1036
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
55
|
1
|
|
|
1
|
|
3
|
elsif ($type =~ /^log(ger)?_sub/ && $name =~ /\Alog_\w+_cluck\z/ ) { $r->[0] = sub { $code->(@_); Carp::cluck ($hook_args{formatters}{default}(@_)."\n") } } |
|
1
|
|
|
|
|
703
|
|
|
1
|
|
|
|
|
6
|
|
56
|
1
|
|
|
1
|
|
6
|
elsif ($type =~ /^log(ger)?_method/ && $name =~ /\A\w+_cluck\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::cluck ($hook_args{formatters}{default}(@_)."\n") } } |
|
1
|
|
|
|
|
974
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
57
|
2
|
|
|
2
|
|
8
|
elsif ($type =~ /^log(ger)?_sub/ && $name =~ /\Alog_\w+_croak\z/ ) { $r->[0] = sub { $code->(@_); Carp::croak ($hook_args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
2
|
|
1622
|
|
|
2
|
|
|
|
|
10
|
|
58
|
2
|
|
|
2
|
|
8
|
elsif ($type =~ /^log(ger)?_method/ && $name =~ /\A\w+_croak\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::croak ($hook_args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
2
|
|
1122
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
7
|
|
59
|
2
|
|
|
2
|
|
9
|
elsif ($type =~ /^log(ger)?_sub/ && $name =~ /\Alog_\w+_confess\z/) { $r->[0] = sub { $code->(@_); Carp::confess($hook_args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
2
|
|
1084
|
|
|
2
|
|
|
|
|
8
|
|
60
|
2
|
|
|
2
|
|
10
|
elsif ($type =~ /^log(ger)?_method/ && $name =~ /\A\w+_confess\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::confess($hook_args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
2
|
|
1492
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
}, |
63
|
1
|
|
|
|
|
10
|
], |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
# ABSTRACT: Add *_{carp,cluck,croak,confess} logging routines |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |