Sprocket/Logger/Log4perl.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 44 CC 2 SCAR 11.0
CC
2
Cov
0%
new
6.0
put
2.0
get_logger
2.0
CRAP 3.0
1 package Sprocket::Logger::Log4perl;
2  
3 use strict;
4 use warnings;
5 use Log::Log4perl;
6 use Log::Log4perl::Level;
7  
8 our %levels = (
9 0 => 'fatal',
10 1 => 'error',
11 2 => 'warn',
12 3 => 'info',
13 4 => 'debug',
14 );
15  
16 sub new {
17 my ($class,$config) = @_;
18 die "Can't open Log4perl config ($config)" unless (ref $config or -r $config);
19 Log::Log4perl::init( $config );
20 return bless {}, $class;
21 }
22  
23 sub put {
24 my ($self, $sprocket, $opts) = @_;
25  
26 my $lvl = $levels{ $opts->{v} } || $levels{ 4 };
27  
28 $self->get_logger->$lvl( $opts->{msg} );
29 }
30  
31 sub get_logger {
32 my $self = shift;
33 return Log::Log4perl::get_logger(@_);
34 }
35  
36 1;