QueryByName/Logger.pm

filter: Statementstmt 53.1% 25 / 47 Branchbran 20.0% 2 / 10 Conditioncond 8.7% 2 / 23 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 42.8% 6 / 14 Podpod 100% 7 / 7 totaltotal 36.8% 42 / 114 CC 12 SCAR 19.4
CC
12
Cov
36%
get_logger
12.0
AUTOLOAD
12.0
debug
12.0
CRAP 7.0
« QueryByName/Result/Iterator.pm ↑ Summary QueryByName.pm »
1 package DBIx::QueryByName::Logger;
2 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our @EXPORT_OK = qw( get_logger debug );
9 1 our $AUTOLOAD;
10  
11 1 my $SELF = bless({},__PACKAGE__);
12  
13 # check whether Log::Log4perl is available...
14 1 my $LOG4PERLEXISTS = 1;
15 0 ▶eval 'use Log::Log4perl';
Subroutine BEGIN: called CC=1 SCAR=1.2
16 1 ▶$LOG4PERLEXISTS = 0 if (defined $@ && $@ ne '');
Branch: 1 branch
BranchTrueFalseTotal
if defined $@ and $@ ne "" 1 0 1
Condition33%1/3
defined $@ and $@ ne ""
!ll&&!rl&&r
001
MC/DC0%0/2
defined $@ and $@ ne ""
defined $@ $@ ne ""
Truth table33%1/3
A and B
A= defined $@B= $@ ne ""
ABresult
0X0
100
111
17  
18 0 ▶sub get_logger {
Subroutine get_logger: not called CC=3 SCAR=24.8
Pod documented
19 0 ▶ return $SELF unless $LOG4PERLEXISTS && Log::Log4perl->initialized();
Branch: 1 branch
BranchTrueFalseTotal
unless $LOG4PERLEXISTS and "Log::Log4perl"->initialized 0 0 0
Condition0%0/3
$LOG4PERLEXISTS and "Log::Log4perl"->initialized
!ll&&!rl&&r
000
MC/DC0%0/2
$LOG4PERLEXISTS and "Log::Log4perl"->initialized
$LOG4PERLEXISTS "Log::Log4perl"->initialized
Truth table0%0/3
A and B
A= $LOG4PERLEXISTSB= "Log::Log4perl"->initialized
ABresult
0X0
100
111
20 0 return Log::Log4perl::get_logger();
21 }
22  
23 # default logger methods
24 0 ▶sub logcroak { my $msg = $_[1] || ''; croak "$msg\n" }
Subroutine logcroak: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
25 0 ▶sub error { my $msg = $_[1] || ''; print STDERR "ERROR: $msg\n" }
Subroutine error: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
26 0 ▶sub warn { my $msg = $_[1] || ''; print STDERR "WARN: $msg\n" }
Subroutine warn: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
27 0 ▶sub info { my $msg = $_[1] || ''; print STDERR "INFO: $msg\n" }
Subroutine info: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
28 0 ▶sub log { my $msg = $_[1] || ''; print STDERR "$msg\n" }
Subroutine log: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
29  
30 # and all the others
31 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
32 0 ▶ my $msg = $_[1] || '';
Condition0%0/2
$_[1] || ''
l!l
00
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
33 0 my $method = $AUTOLOAD;
34 0 ▶ return if ($method =~ /::DESTROY$/);
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ /::DESTROY$/ 0 0 0
35 0 print STDERR "unhandled call to [$method]: $msg\n";
36 }
37  
38 # just print a debug message if need be
39 1 my $SHOWDEBUG=0;
40 1 ▶$SHOWDEBUG=1 if (exists $ENV{DBIXQUERYBYNAMEDEBUG} && "$ENV{DBIXQUERYBYNAMEDEBUG}" == "1");
Branch: 1 branch
BranchTrueFalseTotal
if exists $ENV{"DBIXQUERYBYNAMEDEBUG"} and qq[$ENV{"DBIXQUERYBYNAMEDEBUG"}] == 1 0 1 1
Condition33%1/3
exists $ENV{"DBIXQUERYBYNAMEDEBUG"} and qq[$ENV{"DBIXQUERYBYNAMEDEBUG"}] == 1
!ll&&!rl&&r
100
MC/DC0%0/2
exists $ENV{"DBIXQUERYBYNAMEDEBUG"} and qq[$ENV{"DBIXQUERYBYNAMEDEBUG"}] == 1
exists $ENV{"DBIXQUERYBYNAMEDEBUG"} qq[$ENV{"DBIXQUERYBYNAMEDEBUG"}] == 1
Truth table33%1/3
A and B
A= exists $ENV{"DBIXQUERYBYNAMEDEBUG"}B= qq[$ENV{"DBIXQUERYBYNAMEDEBUG"}] == 1
ABresult
0X0
100
111
41  
42 0 ▶sub debug {
Subroutine debug: not called CC=3 SCAR=24.8
Pod documented
43 0 ▶ return if !$SHOWDEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless $SHOWDEBUG 0 0 0
44 0 ▶ my $msg = shift || '';
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
45 0 my ($sec,$min,$hour,$mday,$mon,$year,$wday,
46 $yday,$isdst)=localtime(time);
47 0 print STDERR "DEBUG (pid:$$ at ".sprintf("%02d:%02d:%02d",$hour,$min,$sec)."): $msg\n";
48 }
49  
50 1 1;
51  
52 __END__
« QueryByName/Result/Iterator.pm ↑ Summary QueryByName.pm »