File Coverage

blib/lib/DBIx/Class/DeploymentHandler/LogRouter.pm
Criterion Covered Total %
statement 14 16 87.5
branch 1 2 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 3 0.0
total 22 30 73.3


line stmt bran cond sub pod time code
1             package DBIx::Class::DeploymentHandler::LogRouter;
2             $DBIx::Class::DeploymentHandler::LogRouter::VERSION = '0.002231';
3 19     19   9537 use Moo;
  19         242080  
  19         100  
4 19     19   96250 use DBIx::Class::DeploymentHandler::Logger;
  19         61  
  19         3558  
5              
6             with 'Log::Contextual::Role::Router';
7              
8             has _logger => (
9             is => 'lazy',
10 18     18   576 builder => sub { DBIx::Class::DeploymentHandler::Logger->new },
11             );
12              
13             sub handle_log_request {
14 381     381 0 6901 my ($self, %message_info) = @_;
15              
16 381         932 my $log_code_block = $message_info{message_sub};
17 381         752 my $args = $message_info{message_args};
18 381         715 my $log_level_name = $message_info{message_level};
19 381         7812 my $logger = $self->_logger;
20 381         5361 my $is_active = $logger->can("is_${log_level_name}");
21              
22 381 50 33     2075 return unless defined $is_active && $logger->$is_active;
23              
24 0           my $log_message = $log_code_block->(@$args);
25              
26 0           $self->_logger->$log_level_name($log_message);
27             }
28              
29       41 0   sub before_import {}
30       41 0   sub after_import {}
31              
32             1;