File: DebugCustom.pm

package info (click to toggle)
opensrs-client 2.9.5-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,712 kB
  • ctags: 982
  • sloc: perl: 24,323; makefile: 61
file content (122 lines) | stat: -rw-r--r-- 3,102 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
######################################
package  DebugCustom;
######################################

##############################################################
=head1 NAME   
  DebugCustom  - A module for debugging
=head1 VERSION 
  $Id: DebugCustom.pm,v 1.4 2001/03/20 14:57:48 zdimic Exp $ 
=head1 SYNOPSIS     
  my $obj = new DebugCustom(DEBUG => "1"); - to turn it on
  my $obj = new DebugCustom(DEBUG => "0"); - to turn it off 
=head1 DESCRIPTION
  this module is used for debug printing
=cut 
###############################################################

$DebugCustom::AB_DEBUG=0;

sub new
{
   my $this     = shift;
   my %args     = @_;
   my $self     = {};  
   bless $self; 

    #print "args=@_\n";
    #print "args{DEBUG}= $args{DEBUG}"; 

   if ( defined $args{DEBUG}) {
       if ($args{DEBUG} == 1) {
          print "Module $0 is running in DEBUG mode\n";
       }
       $DebugCustom::AB_DEBUG=$args{DEBUG};
       #print "DebugCustom::AB_DEBUG=$DebugCustom::AB_DEBUG\n";    
   }

   return $self;
}

####################################################
# <p> debug print
# @param $string - any debug string
####################################################
sub debug_print {
   my $self = shift;
   if ($DebugCustom::AB_DEBUG) {
      my $string = $_[0];
      print "$string\n";
   }
} 

####################################################
# <p> debug print (multi-line)
# @param $string - any debug string
# @param @params - parameters to print
####################################################
sub debug_print_m  {
   my $self = shift; 
   if ($DebugCustom::AB_DEBUG) {
     my  $string = $_[0];
     my $i;
      print "$string \n";
      for($i=1; $i<@_; $i++) {
           print "  $i:    $_[$i] \n";
       }
    }
}    

####################################################
# <p>DEBUG  PRINT Array
# @param - $string - header string
# @param @array - array to print
####################################################
sub debug_print_array {
   my $self = shift;
   if ($DebugCustom::AB_DEBUG) { 
      my  $string = $_[0];
      print "$string \n";
      my $i;
      for($i=1; $i<@_; $i++) {
         print "  $i:    $_[$i] \n";
      }
   }
}      

####################################################
# <p> PRINT Array
# @param - $string - header string
# @param @array - array to print
####################################################
sub print_array {
   my $self = shift;
   my  $string = $_[0];
   print "$string \n";
   my $i;
   my $j=0;
   for($i=1; $i<@_; $i++) { 
         print "  $j:    $_[$i] \n";
   }
}

#######################################################
# <p> PRINT Hash 
# @param - $string - header string
# @param - $hash_ref - reference to hash array to print
#######################################################
sub debug_print_hash {
   if ($DebugCustom::AB_DEBUG) { 
   	my $self = shift;
   	my  ($string, $hash_ref) = @_; 
   	print "$string \n";
   	
   	my $j=0;
   	foreach $key (sort keys %{$hash_ref}) {
       	   $j++;
       	   print "  $j:  key=$key   value=$hash_ref->{$key} \n";
   	}
   }
}       
 
1;