Subversion Repositories gelsvn

Rev

Rev 107 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 bj 1
package OutputMessage;
2
 
3
# ************************************************************
4
# Description   : Prints information, warnings and errors.
5
# Author        : Chad Elliott
6
# Create Date   : 2/02/2004
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
 
15
# ************************************************************
16
# Data Section
17
# ************************************************************
18
 
19
my($information) = 'INFORMATION: ';
20
my($warning)     = 'WARNING: ';
21
my($error)       = 'ERROR: ';
22
 
23
# ************************************************************
24
# Subroutine Section
25
# ************************************************************
26
 
27
sub new {
28
  my($class)   = shift;
29
  my($info)    = shift;
30
  my($warn)    = shift;
31
  my($diag)    = shift;
32
  my($details) = shift;
33
  my($self)    = bless {'information' => $info,
34
                        'warnings'    => $warn,
35
                        'diagnostic'  => $diag,
36
                        'details'     => $details,
37
                       }, $class;
38
  return $self;
39
}
40
 
41
 
42
sub split_message {
43
  my($self) = shift;
44
  my($msg)  = shift;
45
  my($spc)  = shift;
46
 
47
  $msg =~ s/\.\s+/.\n$spc/g;
48
  return $msg . "\n";
49
}
50
 
51
 
52
sub details {
53
  my($self) = shift;
54
  my($msg)  = shift;
55
 
56
  if ($self->{'details'}) {
57
    print "$msg\n";
58
  }
59
}
60
 
61
 
62
sub diagnostic {
63
  my($self) = shift;
64
  my($msg)  = shift;
65
 
66
  if ($self->{'diagnostic'}) {
67
    print "$msg\n";
68
  }
69
}
70
 
71
 
72
sub information {
73
  my($self) = shift;
74
  my($msg)  = shift;
75
 
76
  if ($self->{'information'}) {
77
    print $information . $self->split_message($msg, ' ' x
78
                                              length($information));
79
  }
80
}
81
 
82
 
83
sub warning {
84
  my($self) = shift;
85
  my($msg)  = shift;
86
 
87
  if ($self->{'warnings'}) {
88
    print $warning . $self->split_message($msg, ' ' x
89
                                          length($warning));
90
  }
91
}
92
 
93
 
94
sub error {
95
  my($self) = shift;
96
  my($msg)  = shift;
97
  my($pre)  = shift;
98
 
99
  if (defined $pre) {
100
    print STDERR "$pre\n";
101
  }
102
  print STDERR $error . $self->split_message($msg, ' ' x
103
                                             length($error));
104
}
105
 
106
 
107
1;