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