File Coverage

blib/lib/Web/AssetLib/Role/Logger.pm
Criterion Covered Total %
statement 31 38 81.5
branch n/a
condition n/a
subroutine 7 8 87.5
pod 0 1 0.0
total 38 47 80.8


line stmt bran cond sub pod time code
1             package Web::AssetLib::Role::Logger;
2              
3 18     18   10684260 use Moose::Role;
  18         342894  
  18         65  
4 18     18   71522 use Data::Dump 1.16;
  18         64969  
  18         1048  
5 18     18   6729 use Data::Dump::Filtered qw/dump_filtered/;
  18         4781  
  18         857  
6              
7 18     18   178 use v5.14;
  18         41  
8 18     18   85 no if $] >= 5.018, warnings => "experimental";
  18         24  
  18         127  
9              
10             with 'MooseX::Log::Log4perl';
11              
12             my $dumpFilterCallback = sub {
13             my ( $ctx, $oref ) = @_;
14              
15             return unless $ctx->class;
16              
17             for ( $ctx->class ) {
18             when ("DateTime") {
19             return { dump => qq($oref) };
20             }
21             }
22             };
23              
24             sub Log::Log4perl::Logger::dump {
25 7     7 0 332 my ( $self, $message, $argsref, $loglevel ) = @_;
26              
27 7         10 $Log::Log4perl::caller_depth += 1;
28              
29 7         11 local $Data::Dumper::Terse = 1;
30              
31             my $coderef = sub {
32 0     0   0 return $message . dump_filtered( $argsref, $dumpFilterCallback );
33 7         30 };
34 7         17 for ($loglevel) {
35 7         14 when (undef) { $self->trace($coderef); }
  0         0  
36 7         20 when (/^debug$/i) { $self->debug($coderef); }
  0         0  
37 7         16 when (/^info$/i) { $self->info($coderef); }
  0         0  
38 7         13 when (/^warn$/i) { $self->warn($coderef); }
  0         0  
39 7         14 when (/^error$/i) { $self->error($coderef); }
  0         0  
40 7         11 when (/^fatal$/i) { $self->fatal($coderef); }
  0         0  
41 7         12 default { $self->trace($coderef); }
  7         40  
42             }
43              
44 7         91 $Log::Log4perl::caller_depth -= 1;
45             }
46              
47 18     18   5312 no Moose::Role;
  18         33  
  18         113  
48              
49             1;
50             __END__