diff options
author | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2010-02-24 20:20:21 +0000 |
---|---|---|
committer | Abdullah Sowayan <sowayan@users.noreply.github.com> | 2010-02-24 20:20:21 +0000 |
commit | 035b47c1a6985e2b884182ab0f3bb1afa714a48f (patch) | |
tree | 48d75721f242b7a0eb4398a65b672a152bdaa37f /ACE/MPC/modules/OutputMessage.pm | |
parent | a3894e5127aa8cf1892e717ab30f02e053cdb482 (diff) | |
download | ATCD-ACE+TAO+CIAO-5_7_6_NGC_Patches.tar.gz |
Diffstat (limited to 'ACE/MPC/modules/OutputMessage.pm')
-rw-r--r-- | ACE/MPC/modules/OutputMessage.pm | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/ACE/MPC/modules/OutputMessage.pm b/ACE/MPC/modules/OutputMessage.pm new file mode 100644 index 00000000000..58636c7823f --- /dev/null +++ b/ACE/MPC/modules/OutputMessage.pm @@ -0,0 +1,106 @@ +package OutputMessage; + +# ************************************************************ +# Description : Prints information, warnings and errors. +# Author : Chad Elliott +# Create Date : 2/02/2004 +# ************************************************************ + +# ************************************************************ +# Pragmas +# ************************************************************ + +use strict; + +# ************************************************************ +# Data Section +# ************************************************************ + +my $debugtag = 'DEBUG: '; +my $infotag = 'INFORMATION: '; +my $warntag = 'WARNING: '; +my $errortag = 'ERROR: '; + +my $debug = 0; +my $information = 0; +my $warnings = 1; +my $diagnostic = 1; +my $details = 1; + +# ************************************************************ +# Subroutine Section +# ************************************************************ + +sub new { + my $class = shift; + return bless {}, $class; +} + + +sub set_levels { + my $str = shift; + + if (defined $str) { + $debug = ($str =~ /debug\s*=\s*(\d+)/i ? $1 : 0); + $details = ($str =~ /detail(s)?\s*=\s*(\d+)/i ? $2 : 0); + $diagnostic = ($str =~ /diag(nostic)?\s*=\s*(\d+)/i ? $2 : 0); + $information = ($str =~ /info(rmation)?\s*=\s*(\d+)/i ? $2 : 0); + $warnings = ($str =~ /warn(ing)?\s*=\s*(\d+)/i ? $2 : 0); + } +} + +sub split_message { + my($self, $msg, $spc) = @_; + $msg =~ s/\.\s+/.\n$spc/g; + return $msg . "\n"; +} + + +sub details { + if ($details) { + #my($self, $msg) = @_; + print "$_[1]\n"; + } +} + + +sub diagnostic { + if ($diagnostic) { + #my($self, $msg) = @_; + print "$_[1]\n"; + } +} + + +sub debug { + if ($debug) { + #my($self, $msg) = @_; + print "$debugtag$_[1]\n"; + } +} + + +sub information { + if ($information) { + #my($self, $msg) = @_; + print $infotag, $_[0]->split_message($_[1], ' ' x length($infotag)); + } +} + + +sub warning { + if ($warnings) { + #my($self, $msg) = @_; + print $warntag, $_[0]->split_message($_[1], ' ' x length($warntag)); + } +} + + +sub error { + my($self, $msg, $pre) = @_; + print STDERR '', (defined $pre ? "$pre\n" : ''), $errortag, + $self->split_message($msg, ' ' x length($errortag)); +} + + +1; |