blib/lib/Catalyst/Plugin/Log/Handler.pm

filter: Statementstmt 96.4% 55 / 57 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 92.8% 13 / 14 Podpod 0.0% 0 / 1 totaltotal 91.1% 72 / 79 CC 3 SCAR 2.4
CC
3
Cov
94%
new
2.0
setup
2.0
__ANON__
1.1
CRAP 1.3
↑ Summary
1 package Catalyst::Plugin::Log::Handler;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 Catalyst::Plugin::Log::Handler - Catalyst Plugin for Log::Handler
8  
9 =head1 VERSION
10  
11 Version 0.08
12  
13 =cut
14  
15 3 our $VERSION = '0.08';
16  
17 3 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶sub setup {
Subroutine setup: called CC=2 SCAR=7.0
Pod undocumented
20 1 my $c = shift;
21  
22 1 ▶ my $config = $c->config->{'Log::Handler'} || {};
Condition50%1/2
$c->config->{'Log::Handler'} || {}
l!l
10
MC/DC0%0/1
$c->config->{'Log::Handler'} || {}
$c->config->{'Log::Handler'}
Truth table50%1/2
A
A= $c->config->{'Log::Handler'}
Aresult
11
00
23  
24 1 $c->log((__PACKAGE__ . '::Backend')->new($config));
25  
26 1 return $c->maybe::next::method(@_);
27 }
28  
29  
30 package Catalyst::Plugin::Log::Handler::Backend;
31 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 3 ▶use base qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 3 ▶use Log::Handler 0.63;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 3 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 3 __PACKAGE__->mk_accessors(qw(handler));
38  
39 3 my %cat_to_handler_level = (
40 debug => 'debug',
41 info => 'info',
42 warn => 'warning',
43 error => 'error',
44 fatal => 'emergency',
45 );
46  
47 {
48  
49 3 ▶ while (my ($catlevel, $handlerlevel) = each %cat_to_handler_level) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %cat_to_handler_level) 15 3 18
50  
51 5 ▶ my $logsub = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
52 5 my $self = shift;
53  
54 5 $self->handler->$handlerlevel(@_);
55 15 };
56  
57 15 my $handlerfunc = "is_$handlerlevel";
58 5 ▶ my $testsub = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
59 5 my $self = shift;
60  
61 5 $self->handler->$handlerfunc();
62 15 };
63  
64 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
65 15 *{$catlevel} = $logsub;
66 15 *{"is_$catlevel"} = $testsub;
67 }
68 }
69  
70 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
71 1 my $class = shift;
72 1 my $self = $class->next::method();
73  
74 1 my ($config) = @_;
75  
76 1 ▶ unless (exists $config->{filename}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $config->{"filename"}) 0 1 1
77 0 warn "There's no Log::Handler->filename in your Catalyst ".
78 "app configuration.\n";
79 }
80  
81 # Log::Handler->new will fail if there's no filename in the conf. But let's
82 # try it anyway to convince the user.
83  
84 1 $self->handler(Log::Handler->new( file => {
85 minlevel => 0,
86 maxlevel => 7,
87 %$config,
88 } ));
89 1 return $self;
90 }
91  
92 0 ▶*levels = *enable = *disable = sub { return 0; };
Subroutine __ANON__: not called CC=1 SCAR=1.2
93  
94 3 1;
95 __END__
↑ Summary