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