lib/XT/Files/Role/Logger.pm

filter: Statementstmt 100% 41 / 41 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 100% 4 / 4 totaltotal 100% 59 / 59 CC 2 SCAR 1.4
CC
2
Cov
100%
log_debug
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« lib/Test/XTFiles.pm ↑ Summary corpus/dist1/xt/lib/Local/Bad1.pm »
1 package XT::Files::Role::Logger;
2  
3 35 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 35 our $VERSION = '0.001';
8  
9 35 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 35 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 35 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 35 ▶use Test::Builder ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 sub log { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
16 30 ▶ my ( $self, $msg ) = @_;
Subroutine log: called CC=1 SCAR=0.0
Pod documented
17  
18 30 my $msg_with_prefix = $self->_msg_with_prefix($msg);
19 30 Test::Builder->new->note($msg_with_prefix);
20  
21 30 return;
22 }
23  
24 sub log_debug {
25 12 ▶ my ( $self, $msg ) = @_;
Subroutine log_debug: called CC=2 SCAR=6.9
Pod documented
26  
27 12 ▶ return if !$ENV{XT_FILES_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"XT_FILES_DEBUG"} 10 2 12
28  
29 2 $self->log($msg);
30  
31 2 return;
32 }
33  
34 sub log_fatal {
35 26 ▶ my ( $self, $msg ) = @_;
Subroutine log_fatal: called CC=1 SCAR=0.0
Pod documented
36  
37 26 $self->log($msg);
38  
39 26 my $msg_with_prefix = $self->_msg_with_prefix($msg);
40  
41 26 my $package = __PACKAGE__;
42 26 local $Carp::CarpInternal{$package} = 1; ## no critic (Variables::ProhibitPackageVars)
43 26 Carp::confess($msg_with_prefix);
44 }
45  
46 sub log_prefix {
47 39 ▶ my ($self) = @_;
Subroutine log_prefix: called CC=1 SCAR=0.0
Pod documented
48  
49 39 return Scalar::Util::blessed($self);
50 }
51  
52 sub _msg_with_prefix {
53 56 ▶ my ( $self, $msg ) = @_;
Subroutine _msg_with_prefix: called CC=1 SCAR=0.0
54  
55 56 my $msg_with_prefix = '[' . $self->log_prefix . '] ' . $msg;
56 56 return $msg_with_prefix;
57 }
58  
59 35 1;
60  
61 __END__
« lib/Test/XTFiles.pm ↑ Summary corpus/dist1/xt/lib/Local/Bad1.pm »