File Coverage

blib/lib/Gears/Logger/Handler.pm
Criterion Covered Total %
statement 29 29 100.0
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 37 39 94.8


line stmt bran cond sub pod time code
1             package Gears::Logger::Handler;
2             $Gears::Logger::Handler::VERSION = '0.102';
3 1     1   15 use v5.40;
  1         5  
4 1     1   9 use Mooish::Base -standard;
  1         2  
  1         12  
5              
6 1     1   20864 use Gears::X::Logger;
  1         27656  
  1         70  
7 1     1   1267 use Log::Handler;
  1         64425  
  1         8  
8              
9             extends 'Gears::Logger';
10              
11             has param 'outputs' => (
12             isa => ArrayRef,
13             );
14              
15             has field 'handler' => (
16             lazy => 1,
17             );
18              
19             sub _build_handler ($self)
20 1     1   14 {
  1         2  
  1         2  
21 1         8 my @conf = $self->outputs->@*;
22 1 50       7 if (defined $self->log_format) {
23 1         4 for my $conf_key (grep { $_ % 2 } keys @conf) {
  2         7  
24 1         4 my $name = $conf[$conf_key - 1];
25 1         2 my $conf = $conf[$conf_key];
26              
27             Gears::X::Logger->raise("both message_layout and logger's log_format specified for '$name'")
28 1 50       5 if exists $conf->{message_layout};
29              
30 1         5 $conf->{message_layout} = '%m%N';
31             }
32             }
33              
34 1         12 return Log::Handler->new(@conf);
35             }
36              
37 4         10 sub _log_message ($self, $level, $message)
  4         9  
38 4     4   948 {
  4         7  
  4         5  
39 4         147 $self->handler->log($level, $message);
40             }
41