| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
$debug_level >= $level and @_
MC/DC0%0/2
$debug_level >= $level and @_
$debug_level >= $level
@_
Truth table33%1/3
A and B
A= $debug_level >= $levelB= @_
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if($debug_file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if(my $fh = IO::File->new($debug_file, 'a+')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||