HiD/Role/DoesLogging.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 94.5% 35 / 37 CC 3 SCAR 5.6
CC
3
Cov
97%
__ANON__
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« HiD/VirtualPage.pm ↑ Summary HiD/Role/IsPublished.pm »
1 #ABSTRACT: Logging role
2  
3 package HiD::Role::DoesLogging;
4 20 our $AUTHORITY = 'cpan:GENEHACK';
5 20 $HiD::Role::DoesLogging::VERSION = '1.96';
6 20 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 20 ▶use 5.014; # strict, unicode_strings
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 20 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 20 requires 'get_config';
13  
14  
15 has logger_config => (
16 is => 'ro' ,
17 isa => 'HashRef',
18 lazy => 1 ,
19 default => sub {
20 17 ▶ my $self = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
21 17 my $config = $self->get_config('logger_config');
22  
23 17 ▶ return $config
Branch: 1 branch
BranchTrueFalseTotal
if $config and %$config 14 3 17
Condition66%2/3
$config and %$config
!ll&&!rl&&r
3014
MC/DC50%1/2
$config and %$config
$config %$config
Truth table66%2/3
A and B
A= $configB= %$config
ABresult
0X0
100
111
24 if ( $config && %$config );
25  
26 return {
27 3 'log4perl.logger' => 'WARN, Screen' ,
28 'log4perl.appender.Screen' => 'Log::Log4perl::Appender::Screen',
29 'log4perl.appender.Screen.layout' => 'PatternLayout' ,
30 'log4perl.appender.Screen.layout.ConversionPattern' => '[%d] %5p %m%n' ,
31 };
32 },
33 20 );
34  
35  
36 20 has logger => (
37 is => 'ro' ,
38 isa => 'Log::Log4perl::Logger',
39 lazy => 1 ,
40 builder => '_build_logger' ,
41 handles => {
42 DEBUG => 'debug' ,
43 WARN => 'warn' ,
44 INFO => 'info' ,
45 ERROR => 'error' ,
46 FATAL => 'fatal' ,
47 LOGWARN => 'logwarn' ,
48 },
49 );
50  
51 sub _build_logger {
52 17 ▶ my $self = shift;
Subroutine _build_logger: called CC=1 SCAR=0.0
53  
54 17 Log::Log4perl->init( $self->logger_config );
55 17 Log::Log4perl->get_logger();
56 }
57  
58 20 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 20 1;
60  
61 __END__
62  
63 =pod
64  
65 =encoding UTF-8
66  
67 =head1 NAME
68  
69 HiD::Role::DoesLogging - Logging role
70  
71 =head1 ATTRIBUTES
72  
73 =head2 logger_config
74  
75 Configuration for logging. Defaults to:
76  
77 log4perl.logger = DEBUG, Screen
78 log4perl.appender.Screen = Log::Log4perl::Appender::Screen
79 log4perl.appender.Screen.layout = PatternLayout
80 log4perl.appender.Screen.layout.ConversionPattern = [%d] %5p %m%n
81  
82 =head2 logger
83  
84 Log4perl object for logging. Handles:
85  
86 =over
87  
88 =item * DEBUG
89  
90 =item * WARN
91  
92 =item * INFO
93  
94 =item * ERROR
95  
96 =item * FATAL
97  
98 =back
99  
100 =head1 VERSION
101  
102 version 1.96
103  
104 =head1 AUTHOR
105  
106 John SJ Anderson <genehack@genehack.org>
107  
108 =head1 COPYRIGHT AND LICENSE
109  
110 This software is copyright (c) 2015 by John SJ Anderson.
111  
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114  
115 =cut
« HiD/VirtualPage.pm ↑ Summary HiD/Role/IsPublished.pm »