AST/Impl/Logger.pm

filter: Statementstmt 63.1% 24 / 38 Branchbran 30.0% 3 / 10 Conditioncond 9.0% 1 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 72.7% 8 / 11 Podpod n/a totaltotal 47.3% 36 / 76 CC 11 SCAR 22.7
CC
11
Cov
47%
PRINT
30.0
UNTIE
6.0
TIEHANDLE
5.0
CRAP 9.6
« AST/Grammar/ECMAScript_262_5/StringNumericLiteral/NativeNumberSemantics.pm ↑ Summary AST/Grammar/ECMAScript_262_5/Pattern.pm »
1 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 18 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package MarpaX::Languages::ECMAScript::AST::Impl::Logger;
5  
6 # ABSTRACT: Log::Any implementation on top of Marpa
7  
8 18 ▶use diagnostics;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use MarpaX::Languages::ECMAScript::AST::Exceptions qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use Log::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 18 our $VERSION = '0.020'; # VERSION
13  
14 18 ▶sub BEGIN {
Subroutine BEGIN: called CC=3 SCAR=14.2
15 #
16 ## Some Log implementation specificities
17 #
18 0 ▶ my $log4perl = eval 'use Log::Log4perl; 1;' || 0; ## no critic
Subroutine BEGIN: called CC=1 SCAR=1.2
Condition50%1/2
eval 'use Log::Log4perl; 1;' || 0
l!l
018
MC/DC0%0/1
eval 'use Log::Log4perl; 1;' || 0
eval 'use Log::Log4perl; 1;'
Truth table50%1/2
A
A= eval 'use Log::Log4perl; 1;'
Aresult
11
00
19 18 ▶ if ($log4perl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($log4perl) 0 18 18
20 #
21 ## Here we put know hooks for logger implementations
22 #
23 0 Log::Log4perl->wrapper_register(__PACKAGE__);
24 }
25 }
26  
27 17 ▶sub TIEHANDLE {
Subroutine TIEHANDLE: called CC=4 SCAR=16.1
28 17 my($class, %options) = @_;
29  
30 my $self = {
31 level => exists($options{level}) ? ($options{level} || 'trace') : 'trace',
32 category => exists($options{category}) ? $options{category} : undef, # undef is ok
33 17 ▶ };
Branch: 2 branches
BranchTrueFalseTotal
exists $options{'level'} ? : 0 17 17
exists $options{'category'} ? : 0 17 17
Condition0%0/2
$options{"level"} or "trace"
l!l
00
MC/DC0%0/1
$options{"level"} or "trace"
$options{"level"}
Truth table0%0/2
A
A= $options{"level"}
Aresult
11
00
34  
35 17 $self->{logger} = Log::Any->get_logger(category => $self->{category});
36  
37 17 bless $self, $class;
38 }
39  
40 0 ▶sub PRINT {
Subroutine PRINT: not called CC=5 SCAR=34.0
41 0 my $self = shift;
42 0 ▶ my $logger = $self->{logger} || '';
Condition0%0/2
$self->{'logger'} || ''
l!l
00
MC/DC0%0/1
$self->{'logger'} || ''
$self->{'logger'}
Truth table0%0/2
A
A= $self->{'logger'}
Aresult
11
00
43 0 ▶ my $level = $self->{level} || '';
Condition0%0/2
$self->{'level'} || ''
l!l
00
MC/DC0%0/1
$self->{'level'} || ''
$self->{'level'}
Truth table0%0/2
A
A= $self->{'level'}
Aresult
11
00
44 0 ▶ if ($logger && $level) {
Branch: 1 branch
BranchTrueFalseTotal
if ($logger and $level) 0 0 0
Condition0%0/3
$logger and $level
!ll&&!rl&&r
000
MC/DC0%0/2
$logger and $level
$logger $level
Truth table0%0/3
A and B
A= $loggerB= $level
ABresult
0X0
100
111
45 0 $logger->trace(@_);
46 }
47 0 return 1;
48 }
49  
50 0 ▶sub PRINTF {
Subroutine PRINTF: not called CC=1 SCAR=6.9
51 0 my $self = shift;
52 0 return $self->PRINT(sprintf(@_));
53 }
54  
55 0 ▶sub UNTIE {
Subroutine UNTIE: not called CC=2 SCAR=17.9
56 0 my ($obj, $count) = @_;
57 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
58 0 InternalError(error => "untie attempted while $count inner references still exist");
59 }
60 }
61  
62  
63 18 1;
64  
65 __END__
« AST/Grammar/ECMAScript_262_5/StringNumericLiteral/NativeNumberSemantics.pm ↑ Summary AST/Grammar/ECMAScript_262_5/Pattern.pm »