File Coverage

blib/lib/Log/ger/Layout/JSON.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 23 24 95.8


line stmt bran cond sub pod time code
1             package Log::ger::Layout::JSON;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-03-07'; # DATE
5             our $DIST = 'Log-ger-Layout-JSON'; # DIST
6             our $VERSION = '0.002'; # VERSION
7              
8 1     1   3171 use 5.010001;
  1         6  
9 1     1   4 use strict;
  1         2  
  1         26  
10 1     1   4 use warnings;
  1         1  
  1         24  
11              
12 1     1   4 use parent qw(Log::ger::Layout::LTSV);
  1         2  
  1         5  
13              
14             sub _encode {
15 5     5   12477 my ($pkg, $msg) = @_;
16              
17 5         10 state $json = do {
18 1         5 require JSON::MaybeXS;
19 1         6 JSON::MaybeXS->new->canonical;
20             };
21 5         78 $json->encode($msg);
22             }
23              
24             sub get_hooks {
25 5     5 0 9118 __PACKAGE__->_get_hooks(@_);
26             }
27              
28             1;
29             # ABSTRACT: Layout log message as a JSON object (hash)
30              
31             __END__