| 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
Condition33%1/3
defined $@ and $@ ne ""
MC/DC0%0/2
defined $@ and $@ ne ""
defined $@
$@ ne ""
Truth table33%1/3
A and B
A= defined $@B= $@ ne ""
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$LOG4PERLEXISTS and "Log::Log4perl"->initialized
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
| |||||||||||||||||||||||||||||
| 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] || ''
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 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] || ''
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 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] || ''
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 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] || ''
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 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] || ''
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 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] || ''
MC/DC0%0/1
$_[1] || ''
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 33 | 0 | my $method = $AUTOLOAD; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | return if ($method =~ /::DESTROY$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
exists $ENV{"DBIXQUERYBYNAMEDEBUG"} and qq[$ENV{"DBIXQUERYBYNAMEDEBUG"}] == 1
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
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return if !$SHOWDEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $msg = shift || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||