File Coverage

lib/Log/Mini.pm
Criterion Covered Total %
statement 22 22 100.0
branch 8 8 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 34 35 97.1


line stmt bran cond sub pod time code
1             package Log::Mini;
2              
3 3     3   990550 use strict;
  3         6  
  3         128  
4 3     3   18 use warnings;
  3         5  
  3         223  
5 3     3   2097 use Module::Load qw/load/;
  3         5181  
  3         30  
6              
7             require Carp;
8              
9             our $VERSION = "0.5.3";
10              
11             sub new
12             {
13 8     8 0 473310 shift;
14 8         24 my ($type, @args) = @_;
15              
16 8 100       27 @args = () unless @args;
17              
18 8 100       21 $type = 'stderr' unless defined $type;
19              
20 8 100       20 if ($type eq 'file') {
21 2         7 unshift(@args, $type);
22             }
23              
24 8         21 my $module_name = sprintf('Log::Mini::Logger::%s', uc($type));
25 8         8 my $logger;
26              
27             eval {
28 8         49 load $module_name;
29              
30 7         202 $logger = $module_name->new(@args);
31 8 100       44 } or do { Carp::croak(sprintf("Failed to load adapter: %s, %s\n", $type, $@)) };
  1         889  
32              
33 7         30 return $logger;
34             }
35              
36             1;
37              
38             __END__