Diff/Utils.pm

filter: Statementstmt 62.5% 20 / 32 Branchbran 10.0% 1 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod 100% 3 / 3 totaltotal 52.6% 30 / 57 CC 7 SCAR 21.3
CC
7
Cov
49%
debug
16.2
debug_file
6.0
debug_level
6.0
CRAP 8.4
« Diff/Database.pm ↑ Summary
1 package MySQL::Diff::Utils;
2  
3 =head1 NAME
4  
5 MySQL::Diff::Utils - Supporting functions for MySQL:Diff
6  
7 =head1 SYNOPSIS
8  
9 use MySQL::Diff::Utils qw(debug_level debug);
10  
11 =head1 DESCRIPTION
12  
13 Currently contains the debug message handling routines.
14  
15 =cut
16  
17 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 4 our $VERSION = '0.60';
21  
22 # ------------------------------------------------------------------------------
23 # Libraries
24  
25 4 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 # ------------------------------------------------------------------------------
28 # Export Components
29  
30 4 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
31 4 our @EXPORT_OK = qw(debug_file debug_level debug);
32  
33 # ------------------------------------------------------------------------------
34  
35 =head1 FUNCTIONS
36  
37 =head2 Public Functions
38  
39 Fuller documentation will appear here in time :)
40  
41 =over 4
42  
43 =item * debug_file( $file )
44  
45 Accessor to set/get the current debug log file.
46  
47 =item * debug_level( $level )
48  
49 Accessor to set/get the current debug level for messages.
50  
51 Current levels range from 1 to 4, with 1 being very brief processing messages,
52 2 providing high level process flow messages, 3 providing low level process
53 flow messages and 4 providing data dumps, etc where appropriate.
54  
55 =item * debug
56  
57 Writes to debug log file (if specified) and STDERR the given message, provided
58 is equal to or lower than the current debug level.
59  
60 =back
61  
62 =cut
63  
64 {
65 4 my $debug_file;
66 4 my $debug_level = 0;
67  
68 0 ▶ sub debug_file {
Subroutine debug_file: not called CC=2 SCAR=17.9
Pod documented
69 0 my ($new_debug_file) = @_;
70 0 ▶ $debug_file = $new_debug_file if defined $new_debug_file;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_debug_file 0 0 0
71 0 return $debug_file;
72 }
73  
74 0 ▶ sub debug_level {
Subroutine debug_level: not called CC=2 SCAR=17.9
Pod documented
75 0 my ($new_debug_level) = @_;
76 0 ▶ $debug_level = $new_debug_level if defined $new_debug_level;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_debug_level 0 0 0
77 0 return $debug_level;
78 }
79  
80 19 ▶ sub debug {
Subroutine debug: called CC=5 SCAR=27.8
Pod documented
81 19 my $level = shift;
82 19 ▶ return unless($debug_level >= $level && @_);
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_level >= $level and @_ 19 0 19
Condition33%1/3
$debug_level >= $level and @_
!ll&&!rl&&r
1900
MC/DC0%0/2
$debug_level >= $level and @_
$debug_level >= $level @_
Truth table33%1/3
A and B
A= $debug_level >= $levelB= @_
ABresult
0X0
100
111
83  
84 0 ▶ if($debug_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug_file) 0 0 0
85 0 ▶ if(my $fh = IO::File->new($debug_file, 'a+')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fh = "IO::File"->new($debug_file, "a+")) 0 0 0
86 0 print $fh @_,"\n";
87 0 $fh->close;
88 0 return;
89 }
90 }
91
92 0 print STDERR @_,"\n";
93 }
94
95 }
96  
97 4 1;
98  
99 __END__
« Diff/Database.pm ↑ Summary