line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Plugin::HashArgs; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-03-11'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Log-ger-Plugin-HashArgs'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
68096
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
24
|
|
9
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use Log::ger::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
337
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub meta { +{ |
14
|
2
|
|
|
2
|
0
|
2059
|
v => 2, |
15
|
|
|
|
|
|
|
} } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_hooks { |
18
|
2
|
|
|
2
|
0
|
20
|
my %plugin_conf = @_; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
50
|
|
|
10
|
my $sub_name = $plugin_conf{sub_name} || "log"; |
21
|
2
|
|
100
|
|
|
7
|
my $method_name = $plugin_conf{method_name} || "log"; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return { |
24
|
|
|
|
|
|
|
create_filter => [ |
25
|
|
|
|
|
|
|
__PACKAGE__, # key |
26
|
|
|
|
|
|
|
50, # priority |
27
|
|
|
|
|
|
|
sub { # hook |
28
|
5
|
|
|
5
|
|
423
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $filter = sub { |
31
|
4
|
|
|
|
|
2152
|
my %log_args = @_; |
32
|
|
|
|
|
|
|
# die "$logger_name(): Please specify 'level'" unless exists $log_args{level}; |
33
|
4
|
|
|
|
|
12
|
my $level = Log::ger::Util::numeric_level($log_args{level}); |
34
|
4
|
100
|
|
|
|
31
|
return 0 unless $level <= $Log::ger::Current_Level; |
35
|
2
|
|
|
|
|
4
|
my $per_msg_conf = {level=>$level}; |
36
|
|
|
|
|
|
|
$per_msg_conf->{category} = $log_args{category} |
37
|
2
|
50
|
|
|
|
5
|
if defined $log_args{category}; |
38
|
2
|
|
|
|
|
6
|
$per_msg_conf; |
39
|
5
|
|
|
|
|
17
|
}; |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
16
|
[$filter, 0, 'ml_hashargs']; |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
], |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
create_formatter => [ |
46
|
|
|
|
|
|
|
__PACKAGE__, # key |
47
|
|
|
|
|
|
|
50, # priority |
48
|
|
|
|
|
|
|
sub { # hook |
49
|
5
|
|
|
5
|
|
175
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $formatter = sub { |
52
|
2
|
|
|
|
|
11
|
my %log_args = @_; |
53
|
2
|
|
|
|
|
7
|
$log_args{message}; |
54
|
5
|
|
|
|
|
13
|
}; |
55
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
14
|
[$formatter, 0, 'ml_hashargs']; |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
], |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
create_routine_names => [ |
61
|
|
|
|
|
|
|
__PACKAGE__, # key |
62
|
|
|
|
|
|
|
50, # priority |
63
|
|
|
|
|
|
|
sub { # hook |
64
|
5
|
|
|
5
|
|
258
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return [{ |
67
|
|
|
|
|
|
|
log_subs => [[$sub_name , undef, 'ml_hashargs', undef, 'ml_hashargs']], |
68
|
|
|
|
|
|
|
log_methods => [[$method_name, undef, 'ml_hashargs', undef, 'ml_hashargs']], |
69
|
5
|
|
|
|
|
23
|
}, $plugin_conf{exclusive}]; |
70
|
|
|
|
|
|
|
}, |
71
|
2
|
|
|
|
|
18
|
], |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
# ABSTRACT: Log using hash arguments |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |