blib/lib/MooseX/Role/LogHandler.pm

filter: Statementstmt 100% 34 / 34 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 97.9% 47 / 48 CC 3 SCAR 4.1
CC
3
Cov
97%
_build_logger
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MooseX::Role::LogHandler;
4  
5  
6 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 $MooseX::Role::LogHandler::VERSION = '0.008';
8 }
9 # ABSTRACT: Role for those who prefer LogHandler
10  
11 2 ▶use MooseX::Role::Parameterized;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Log::Handler;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14
15 2 parameter 'logfile' => ( isa => 'Str | Undef');
16 2 parameter 'logconf' => ( isa => 'HashRef | Undef');
17 2 ▶role {
Subroutine __ANON__: called CC=1 SCAR=0.0
18 2 my $p = shift;
19 2 has 'logger' => (
20 is => 'rw',
21 isa => 'Log::Handler',
22 lazy_build => 1,
23 );
24 has 'logfile' => (
25 is => 'rw',
26 isa => 'Str | Undef',
27 6 ▶ default => sub {$p->logfile}
Subroutine __ANON__: called CC=1 SCAR=0.0
28 2 );
29 has 'logconf' => (
30 is => 'rw',
31 isa => 'HashRef | Undef',
32 6 ▶ default => sub {$p->logconf}
Subroutine __ANON__: called CC=1 SCAR=0.0
33 2 );
34
35 4 ▶ sub _build_logger {
Subroutine _build_logger: called CC=3 SCAR=11.0
36 4 my $self = shift;
37 4 my $logger;
38
39 4 ▶ if( defined $self->logconf ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->logconf) 2 2 4
40 2 $logger = Log::Handler->new( %{ $self->logconf } );
41 2 return $logger;
42 }
43
44 2 ▶ $logger = Log::Handler->new(
Branch: 1 branch
BranchTrueFalseTotal
defined $self->logfile ? : 2 0 2
45 file => {
46 filename => defined($self->logfile) ? $self->logfile : "/tmp/".__PACKAGE__.".log",
47 maxlevel => "debug",
48 minlevel => "warning",
49 message_layout => "%T [%L] [%p] line %l: %m",
50 }
51 );
52 2 return $logger;
53 };
54 2 };
55 2 1;
56 __END__
↑ Summary