Revision: | 1.6 |
Committed: | Wed Aug 17 11:11:48 2005 UTC (19 years, 8 months ago) by sashby |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | V1_1_7, V1_1_6, V1_1_5, V1_2_0-cand7, V1_2_0-cand6, V1_2_0-cand5, V1_2_0-cand4, V1_2_0-cand3, V1_2_0-cand2, V1_2_0-cand1, V1_1_4, V1_1_3, V1_1_2, V1_1_0_reltag8, V1_1_0_reltag7, V1_1_0_reltag6, V1_1_1, V1_1_0_reltag5, V1_1_0_reltag4, V1_1_0_reltag3, V1_1_0_reltag2, V1_1_0_reltag1, V1_1_0_reltag, V1_0_3-p4, V1_1_0_cand3, V1_1_0_cand2, V1_1_0_cand1, HEAD_SM_071214, forV1_1_0, v103_xml_071106, V1_0_3-p3, V1_0_3-p2, V1_1_0, v110p1, V110p6, V110p5, V110p4, V110p3, before110xmlBRmerge, V110p2, V110p1, V1_0_4p1, V1_0_3-p1, V1_0_3, V1_0_2, V1_0_2_p1 |
Branch point for: | forBinLess_SCRAM, HEAD_BRANCH_SM_071214, v200branch, v103_with_xml, v103_branch |
Changes since 1.5: | +1 -1 lines |
Log Message: | Added more POD doc. |
# | Content |
---|---|
1 | =head1 NAME |
2 | |
3 | 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 | Shaun ASHBY |
36 | |
37 | =cut |
38 | |
39 | 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 | else { |
56 | my $id="VERBOSE_".ref($self); |
57 | if ( defined $ENV{$id} ) { |
58 | return $ENV{$id}; |
59 | } |
60 | } |
61 | $self->{verbose}; |
62 | } |
63 | |
64 | sub verbose { |
65 | my $self=shift; |
66 | my $string=shift; |
67 | |
68 | if ( $self->verbosity() ) { |
69 | 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 | } |