Gears/Logger.pm

filter: Statementstmt 96.0% 24 / 25 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 85.3% 35 / 41 CC 5 SCAR 11.4
CC
5
Cov
91%
message
5.0
_log_message
2.0
BEGIN
1.0
CRAP 3.1
« Gears/Template.pm ↑ Summary Gears/Generator.pm »
1 package Gears::Logger;
2 2 $Gears::Logger::VERSION = '0.105';
3 2 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Mooish::Base -standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Time::Piece;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # apache format
10 2 has param 'date_format' => (
11 isa => Str,
12 default => '%a %b %d %T %Y'
13 );
14  
15 # apache-like format
16 2 has param 'log_format' => (
17 isa => Maybe [Str],
18 default => '[%s] [%s] %s'
19 );
20  
21 # implements actual logging of a single message
22 # must be reimplemented
23 0 ▶sub _log_message ($self, $level, $message)
Subroutine _log_message: not called CC=1 SCAR=6.9
24 {
25 0 ...;
26 }
27  
28 4 ▶sub message ($self, $level, @messages)
Subroutine message: called CC=5 SCAR=16.2
Pod documented
29 {
30 4 my $format = $self->log_format;
31 4 my $date;
32  
33 4 for my $message (@messages) {
34 5 ▶ $message = ref $message ? Dumper($message) : $message;
Branch: 1 branch
BranchTrueFalseTotal
ref $message ? : 1 4 5
35 5 chomp $message;
36  
37 5 ▶ if (defined $format) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $format) 5 0 5
38 5 ▶ $date //= localtime->strftime($self->date_format);
Condition66%2/3
$date //= Gears::Logger::localtime()->strftime($self->date_format)
l!l&&r!l&&!r
140
MC/DC0%0/2
$date //= Gears::Logger::localtime()->strftime($self->date_format)
$date Gears::Logger::localtime()->strftime($self->date_format)
Truth table66%2/3
A //= B
A= $dateB= Gears::Logger::localtime()->strftime($self->date_format)
ABresult
1X1
011
000
39 5 $message = sprintf $format, $date, uc $level, $message;
40 }
41  
42 5 $self->_log_message($level, $message);
43 }
44  
45 4 return $self;
46 }
47  
48 __END__
« Gears/Template.pm ↑ Summary Gears/Generator.pm »