head 1.2; access; symbols; locks; strict; comment @# @; 1.2 date 96.10.02.13.55.04; author alexis; state Exp; branches; next 1.1; 1.1 date 96.09.30.17.02.39; author root; state Exp; branches; next ; desc @small fixes @ 1.2 log @works ... subject to merging with fad's msgs.pl @ text @############################################################################### # # BASIC MESSAGE LIBRARY # Copyright (C) 1996 Alexis Huxley # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ############################################################################### ############################################################################### # # CONFIGURABLE THINGS # ############################################################################### $logger_cmd = "/usr/bin/logger"; ############################################################################### # # DON'T CHANGE ANYTHING BELOW HERE # ############################################################################### # stopgap level until things get going - needed by require's. if (!defined $verboselevel) { $verboselevel = 2; } $MSGS_STD = 0; $MSGS_SYS = 1; if (!defined $msgs_mode) { $msgs_mode = $MSGS_STD; } ############################################################################### # # # functions: error, warning, info, internal, debug # # parameters: text # debug function also uses message level # # requires: nothing # # returns: nothing # error exits # # ############################################################################### ($modvers{'msgs.pl'} = '$Header: /home/alexis/dev/ppp-on/RCS/msgs.pl,v 1.1 1996/09/30 17:02:39 root Exp alexis $') =~ s/^.*,v (\S+) .*$/$1/; sub error { local($text) = @@_; if ($verboselevel < 1) { ; } elsif ($msgs_mode == $MSGS_SYS) { system("$logger_cmd -p local0.err -t $progname[$$] \"ERROR: $text\""); } else { print STDERR "$progname: ERROR: $text\n"; } exit 2; } sub warning { local($text) = @@_; if ($verboselevel < 2) { ; } elsif ($msgs_mode == $MSGS_SYS) { system("$logger_cmd -p local0.warning -t $progname[$$] \"WARNING: $text\""); } else { print STDERR "$progname: WARNING: $text\n"; } } sub info { local($text) = @@_; if ($verboselevel < 3) { ; } elsif ($msgs_mode == $MSGS_SYS) { system("$logger_cmd -p local0.info -t $progname[$$] \"INFO: $text\""); } else { print STDERR "$progname: INFO: $text\n"; } } sub internal { local($ie_code, $version, $ie_extras) = @@_; if ($msgs_mode == $MSGS_SYS) { system("$logger_cmd -p local0.debug -t $progname[$$] \"INTERNAL ERROR: contact the sysadmin quoting reference: P $progname V $version C $ie_code $ie_extras\""); } else { print STDERR "$progname: INTERNAL ERROR: contact the sysadmin quoting reference: P $progname V $version C $ie_code $ie_extras\n"; } exit 3; } sub debug { local($msglvl, $text) = @@_; return if ($msglvl > $verboselevel); if ($msgs_mode == $MSGS_SYS) { system("$logger_cmd -p local0.debug -t $progname[$$] DEBUG: $text"); } else { printf STDERR "$progname: DEBUG[%03d]: $text\n", $msglvl; } } 1; @ 1.1 log @Initial revision @ text @d62 1 a62 1 ($modvers{'msgs.pl'} = '$Header: msgs.pl,v 1.6 96/07/26 09:58:00 alexis Exp $') =~ s/^.*,v (\S+) .*$/$1/; d71 1 a71 1 system("$logger_cmd -p local0.err -t $progname[$$] ERROR: $text"); d85 1 a85 1 system("$logger_cmd -p local0.warning -t $progname[$$] WARNING: $text"); d98 1 a98 1 system("$logger_cmd -p local0.info -t $progname[$$] INFO: $text"); d106 1 a106 1 local($ie_code, $ie_extras) = @@_; d109 1 a109 1 system("$logger_cmd -p local0.debug -t $progname[$$] INTERNAL ERROR: contact the sysadmin quoting reference \"P $progname V $version C $ie_code $ie_extras\""); d111 1 a111 1 print STDERR "$progname: INTERNAL ERROR: contact the sysadmin quoting reference \"P $progname V $version C $ie_code $ie_extras\"\n"; @