File Coverage

blib/lib/Log/ger/Layout/ConvertCase.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 6 66.6
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 24 28 85.7


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-09'; # DATE
5             our $DIST = 'Log-ger-Layout-ConvertCase'; # DIST
6             our $VERSION = '0.003'; # VERSION
7              
8 1     1   1459 use strict;
  1         2  
  1         26  
9 1     1   5 use warnings;
  1         1  
  1         188  
10              
11             sub meta { +{
12 2     2 0 657 v => 1,
13             } }
14              
15             sub get_hooks {
16 2     2 0 23 my %plugin_conf = @_;
17 2 50       5 $plugin_conf{case} or die "Please specify case";
18 2 50       11 $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   364 my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook"
26              
27             my $layouter = sub {
28 2 100       1945 $plugin_conf{case} eq 'upper' ? uc($_[0]) : lc($_[0]);
29 2         6 };
30              
31 2         4 [$layouter];
32             },
33 2         13 ],
34             };
35             }
36              
37             1;
38             # ABSTRACT: Example layout plugin to convert the case of message
39              
40             __END__