line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Plugin::WithCarp; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2017-08-04'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
71831
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
10
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
10
|
1
|
|
|
1
|
|
4
|
use Log::ger (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1011
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub get_hooks { |
13
|
1
|
|
|
1
|
0
|
13
|
my %conf = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
return { |
16
|
|
|
|
|
|
|
create_routine_names => [ |
17
|
|
|
|
|
|
|
__PACKAGE__, 50, |
18
|
|
|
|
|
|
|
sub { |
19
|
2
|
|
|
2
|
|
538
|
my %args = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
7
|
my $levels = \%Log::ger::Levels; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return [{ |
24
|
|
|
|
|
|
|
log_subs => [ |
25
|
2
|
|
|
|
|
18
|
(map { (["log_${_}_carp", $_, "default"], ["log_${_}_cluck", $_, "default"]) } |
26
|
12
|
|
|
|
|
32
|
grep {$levels->{$_} == 30} keys %$levels), |
27
|
4
|
|
|
|
|
26
|
(map { (["log_${_}_croak", $_, "default"], ["log_${_}_confess", $_, "default"]) } |
28
|
12
|
50
|
|
|
|
57
|
grep {$levels->{$_} > 0 && $levels->{$_} <= 20} keys %$levels), |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
is_subs => [], |
31
|
|
|
|
|
|
|
log_methods => [ |
32
|
2
|
|
|
|
|
11
|
(map { (["${_}_carp", $_, "default"], ["${_}_cluck", $_, "default"]) } |
33
|
12
|
|
|
|
|
23
|
grep {$levels->{$_} == 30} keys %$levels), |
34
|
4
|
|
|
|
|
35
|
(map { (["${_}_croak", $_, "default"], ["${_}_confess", $_, "default"]) } |
35
|
2
|
50
|
|
|
|
13
|
grep {$levels->{$_} > 0 && $levels->{$_} <= 20} keys %$levels), |
|
12
|
|
|
|
|
33
|
|
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
logml_methods => [ |
38
|
|
|
|
|
|
|
], |
39
|
|
|
|
|
|
|
is_methods => [ |
40
|
|
|
|
|
|
|
], |
41
|
|
|
|
|
|
|
}, 0]; |
42
|
|
|
|
|
|
|
}], |
43
|
|
|
|
|
|
|
before_install_routines => [ |
44
|
|
|
|
|
|
|
__PACKAGE__, 50, |
45
|
|
|
|
|
|
|
sub { |
46
|
2
|
|
|
2
|
|
2707
|
my %args = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# wrap the logger |
49
|
2
|
|
|
|
|
3
|
for my $r (@{ $args{routines} }) { |
|
2
|
|
|
|
|
7
|
|
50
|
36
|
|
|
|
|
81
|
my ($code, $name, $numlevel, $type) = @$r; |
51
|
36
|
100
|
100
|
1
|
|
382
|
if ($type eq 'log_sub' && $name =~ /\Alog_\w+_carp\z/ ) { $r->[0] = sub { $code->(@_); Carp::carp ($args{formatters}{default}(@_)."\n") } } |
|
1
|
100
|
100
|
|
|
5
|
|
|
1
|
100
|
100
|
|
|
263
|
|
|
1
|
100
|
100
|
|
|
6
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
52
|
1
|
|
|
1
|
|
7
|
elsif ($type eq 'log_method' && $name =~ /\A\w+_carp\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::carp ($args{formatters}{default}(@_)."\n") } } |
|
1
|
|
|
|
|
1005
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
53
|
1
|
|
|
1
|
|
7
|
elsif ($type eq 'log_sub' && $name =~ /\Alog_\w+_cluck\z/ ) { $r->[0] = sub { $code->(@_); Carp::cluck ($args{formatters}{default}(@_)."\n") } } |
|
1
|
|
|
|
|
745
|
|
|
1
|
|
|
|
|
6
|
|
54
|
1
|
|
|
1
|
|
5
|
elsif ($type eq 'log_method' && $name =~ /\A\w+_cluck\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::cluck ($args{formatters}{default}(@_)."\n") } } |
|
1
|
|
|
|
|
956
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
55
|
2
|
|
|
2
|
|
13
|
elsif ($type eq 'log_sub' && $name =~ /\Alog_\w+_croak\z/ ) { $r->[0] = sub { $code->(@_); Carp::croak ($args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
|
|
1962
|
|
|
2
|
|
|
|
|
11
|
|
56
|
2
|
|
|
2
|
|
9
|
elsif ($type eq 'log_method' && $name =~ /\A\w+_croak\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::croak ($args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
|
|
1328
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
9
|
|
57
|
2
|
|
|
2
|
|
13
|
elsif ($type eq 'log_sub' && $name =~ /\Alog_\w+_confess\z/) { $r->[0] = sub { $code->(@_); Carp::confess($args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
|
|
1121
|
|
|
2
|
|
|
|
|
9
|
|
58
|
2
|
|
|
2
|
|
14
|
elsif ($type eq 'log_method' && $name =~ /\A\w+_confess\z/ ) { $r->[0] = sub { $code->(@_); shift; Carp::confess($args{formatters}{default}(@_)."\n") } } |
|
2
|
|
|
|
|
1664
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
7
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
}, |
61
|
1
|
|
|
|
|
13
|
], |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
# ABSTRACT: Add *_{carp,cluck,croak,confess} logging routines |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |