File Coverage

blib/lib/DBIx/Class/DeploymentHandler/Logger.pm
Criterion Covered Total %
statement 15 29 51.7
branch 2 12 16.6
condition 2 19 10.5
subroutine 6 10 60.0
pod 6 6 100.0
total 31 76 40.7


line stmt bran cond sub pod time code
1             package DBIx::Class::DeploymentHandler::Logger;
2             $DBIx::Class::DeploymentHandler::Logger::VERSION = '0.002231';
3 19     19   138 use warnings;
  19         48  
  19         622  
4 19     19   104 use strict;
  19         47  
  19         425  
5              
6 19     19   90 use parent 'Log::Contextual::WarnLogger';
  19         44  
  19         141  
7              
8             # trace works the way we want it already
9              
10             # sub is_trace { $_[0]->next::method }
11 262 50   262 1 1002 sub is_debug { $_[0]->is_trace || $_[0]->next::method }
12 156 50   156 1 599 sub is_info { $_[0]->is_debug || $_[0]->next::method }
13              
14             sub is_warn {
15 0     0 1 0 my $orig = $_[0]->next::method;
16 0 0 0     0 return undef if defined $orig && !$orig;
17 0   0     0 return $_[0]->is_info || 1
18             }
19              
20             sub is_error {
21 0     0 1 0 my $orig = $_[0]->next::method;
22 0 0 0     0 return undef if defined $orig && !$orig;
23 0   0     0 return $_[0]->is_warn || 1
24             }
25              
26             sub is_fatal {
27 0     0 1 0 my $orig = $_[0]->next::method;
28 0 0 0     0 return undef if defined $orig && !$orig;
29 0   0     0 return $_[0]->is_error || 1
30             }
31              
32             sub _log {
33 0     0   0 my $self = shift;
34 0         0 my $level = shift;
35 0         0 my $message = join( "\n", @_ );
36 0 0       0 $message .= "\n" unless $message =~ /\n$/;
37 0         0 warn "[DBICDH] [$level] $message";
38             }
39              
40             sub new {
41 18     18 1 75 my ($self, $options, @rest) = @_;
42              
43 18   50     145 $options ||= {};
44 18   50     156 $options->{env_prefix} ||= 'DBICDH';
45              
46 18         106 $self->next::method($options, @rest)
47             }
48              
49             1;