WGS2NCBI/Logger.pm

filter: Statementstmt 85.1% 23 / 27 Branchbran 50.0% 6 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 5 totaltotal 66.6% 36 / 54 CC 8 SCAR 11.0
CC
8
Cov
71%
LOG
5.7
DEBUG
2.1
INFO
2.1
CRAP 3.0
« WGS2NCBI/CdsFeature.pm ↑ Summary WGS2NCBI/Seq.pm »
1 package Bio::WGS2NCBI::Logger;
2 5 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 require Exporter;
4 5 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 our $Complexity = 0;
7 5 our $Verbosity = 0;
8 5 our @EXPORT = qw(DEBUG INFO WARN ERROR);
9 5 our %COLORS = (
10 'DEBUG' => 'blue',
11 'INFO' => 'green',
12 'WARN' => 'yellow',
13 'ERROR' => 'red',
14 );
15  
16 6 ▶sub LOG ($$) {
Subroutine LOG: called CC=4 SCAR=17.3
Pod undocumented
17 6 my ($msg,$method) = @_;
18  
19 # compose the message. Complex messages do some amount of introspection
20 # to figure out where the message originated.
21 6 my $log;
22 6 ▶ if ( $Complexity ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Complexity) { } 0 6 6
23 0 my ( $package, $file1up, $line1up, $sub ) = caller( 2 );
24 0 my ( $pack0up, $file, $line, $sub0up ) = caller( 1 );
25 0 ▶ $log = sprintf( "%s %s [%s %s] - %s\n", uc $method, $sub || '', $file, $line, $msg );
Condition0%0/2
$sub || ''
l!l
00
MC/DC0%0/1
$sub || ''
$sub
Truth table0%0/2
A
A= $sub
Aresult
11
00
26 }
27 else {
28 6 $log = $method . ' ' . $msg . "\n";
29 }
30
31 # check if we are actually writing to the terminal rather than a file
32 6 ▶ if ( -t STDERR ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-t STDERR) { } 0 6 6
33 0 print STDERR colored( $log, $COLORS{$method} );
34 }
35 else {
36 6 print STDERR $log;
37 }
38 6 return $Verbosity;
39 }
40 4 ▶sub DEBUG ($) { LOG shift, 'DEBUG' if $Verbosity >= 3 }
Subroutine DEBUG: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $Verbosity >= 3 0 4 4
41 1 ▶sub INFO ($) { LOG shift, 'INFO' if $Verbosity >= 2 }
Subroutine INFO: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $Verbosity >= 2 0 1 1
42 5 ▶sub WARN ($) { LOG shift, 'WARN' if $Verbosity >= 1 }
Subroutine WARN: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $Verbosity >= 1 0 5 5
43 6 ▶sub ERROR ($) { LOG shift, 'ERROR' if $Verbosity >= 0 }
Subroutine ERROR: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $Verbosity >= 0 6 0 6
44  
45 5 1;
« WGS2NCBI/CdsFeature.pm ↑ Summary WGS2NCBI/Seq.pm »