ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/Verbose.pm
Revision: 1.7
Committed: Fri Jan 14 17:36:44 2011 UTC (14 years, 3 months ago) by muzaffar
Content type: text/plain
Branch: MAIN
CVS Tags: V2_2_5_pre2, V2_2_5_pre1, V2_2_4, V2_2_4_pre9, V2_2_4_pre8, V2_2_4_pre7, V2_2_4_pre6, V2_2_4_pre5, V2_2_4_pre4, V2_2_4_pre3, V2_2_4_pre2, V2_2_4_pre1, V2_2_3, forV2_2_3, HEAD
Changes since 1.6: +3 -0 lines
Log Message:
merged SCRAM_V2 branch in to head

File Contents

# User Rev Content
1 sashby 1.5 =head1 NAME
2 williamc 1.2
3 sashby 1.5 Utilities::Verbose - Add verbosity to the current package.
4    
5     =head1 DESCRIPTION
6    
7     Provide a verbosity framework.
8    
9     =head1 METHODS
10    
11     =over
12    
13     =cut
14    
15     =item C<new()>
16    
17     A new Verbose object.
18    
19     =item C<verbose(string)>
20    
21     Print string in verbosity mode.
22    
23     =item C<verbosity($sw)>
24    
25     Turn verbosity on or off ($sw is 0 or 1).
26    
27     =back
28    
29     =head1 AUTHOR
30    
31     Originally Written by Christopher Williams.
32    
33     =head1 MAINTAINER
34    
35 sashby 1.6 Shaun ASHBY
36 sashby 1.5
37     =cut
38    
39 williamc 1.2 package Utilities::Verbose;
40     require 5.004;
41    
42     sub new {
43     my $class=shift;
44     $self={};
45     bless $self, $class;
46     $self->verbose("New ".ref($self)." Created");
47     return $self;
48     }
49    
50     sub verbosity {
51     my $self=shift;
52     if ( @_ ) {
53     $self->{verbose}=shift;
54     }
55 williamc 1.3 else {
56     my $id="VERBOSE_".ref($self);
57     if ( defined $ENV{$id} ) {
58     return $ENV{$id};
59     }
60     }
61 williamc 1.2 $self->{verbose};
62     }
63    
64     sub verbose {
65     my $self=shift;
66     my $string=shift;
67    
68 williamc 1.3 if ( $self->verbosity() ) {
69 williamc 1.2 print ">".ref($self)."($self) : \n->".$string."\n";
70     }
71     }
72    
73     sub error {
74     my $self=shift;
75     my $string=shift;
76    
77     print $string."\n";
78     exit 1;
79     }
80 muzaffar 1.7
81     1;
82