line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Layout::ConvertCase; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-03-11'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Log-ger-Layout-ConvertCase'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1407
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
9
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
175
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub meta { +{ |
12
|
2
|
|
|
2
|
0
|
642
|
v => 2, |
13
|
|
|
|
|
|
|
} } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_hooks { |
16
|
2
|
|
|
2
|
0
|
23
|
my %plugin_conf = @_; |
17
|
2
|
50
|
|
|
|
6
|
$plugin_conf{case} or die "Please specify case"; |
18
|
2
|
50
|
|
|
|
10
|
$plugin_conf{case} =~ /\A(upper|lower)\z/ |
19
|
|
|
|
|
|
|
or die "Invalid value for 'case', please use 'upper' or 'lower'"; |
20
|
|
|
|
|
|
|
return { |
21
|
|
|
|
|
|
|
create_layouter => [ |
22
|
|
|
|
|
|
|
__PACKAGE__, # key |
23
|
|
|
|
|
|
|
50, # priority |
24
|
|
|
|
|
|
|
sub { # hook |
25
|
2
|
|
|
2
|
|
370
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $layouter = sub { |
28
|
2
|
100
|
|
|
|
2029
|
$plugin_conf{case} eq 'upper' ? uc($_[0]) : lc($_[0]); |
29
|
2
|
|
|
|
|
6
|
}; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
5
|
[$layouter]; |
32
|
|
|
|
|
|
|
}, |
33
|
2
|
|
|
|
|
13
|
], |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
# ABSTRACT: Example layout plugin to convert the case of message |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |