forked from extern/shorewall_code
Timestamp error messages; log fatal errors
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@7734 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
1a234e49fa
commit
9d5e2f7941
@ -424,6 +424,8 @@ INIT {
|
||||
initialize;
|
||||
}
|
||||
|
||||
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
|
||||
|
||||
#
|
||||
# Issue a Warning Message
|
||||
#
|
||||
@ -431,9 +433,15 @@ sub warning_message
|
||||
{
|
||||
my $linenumber = $currentlinenumber || 1;
|
||||
my $currentlineinfo = $currentfile ? " : $currentfilename (line $linenumber)" : '';
|
||||
my @localtime;
|
||||
|
||||
$| = 1;
|
||||
|
||||
if ( $log ) {
|
||||
@localtime = localtime;
|
||||
printf $log '%s %02d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
||||
}
|
||||
|
||||
if ( $debug ) {
|
||||
print STDERR longmess( " WARNING: @_$currentlineinfo" );
|
||||
print $log longmess( " WARNING: @_$currentlineinfo" ) if $log;
|
||||
@ -455,6 +463,9 @@ sub fatal_error {
|
||||
$| = 1;
|
||||
|
||||
if ( $log ) {
|
||||
my @localtime = localtime;
|
||||
printf $log '%s %02d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
||||
|
||||
if ( $debug ) {
|
||||
print $log longmess( " ERROR: @_$currentlineinfo" );
|
||||
} else {
|
||||
@ -473,6 +484,9 @@ sub fatal_error1 {
|
||||
$| = 1;
|
||||
|
||||
if ( $log ) {
|
||||
my @localtime = localtime;
|
||||
printf $log '%s %02d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
||||
|
||||
if ( $debug ) {
|
||||
print $log longmess( " ERROR: @_\n" );
|
||||
} else {
|
||||
@ -601,8 +615,6 @@ sub timestamp() {
|
||||
printf '%02d:%02d:%02d ', ( localtime ) [2,1,0];
|
||||
}
|
||||
|
||||
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
|
||||
|
||||
#
|
||||
# Write a message if $verbose >= 2
|
||||
#
|
||||
|
@ -49,6 +49,12 @@ clear_firewall() {
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
|
||||
fi
|
||||
|
||||
stop_firewall
|
||||
[ -n "$TEMPFILE" ] && rm -f $TEMPFILE
|
||||
exit 2
|
||||
@ -72,6 +78,22 @@ startup_error() # $* = Error Message
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
|
||||
case $COMMAND in
|
||||
start)
|
||||
echo "${timestamp} ERROR:$PRODUCT start failed" >> $STARTUP_LOG
|
||||
;;
|
||||
restart)
|
||||
echo "${timestamp} ERROR:$PRODUCT restart failed" >> $STARTUP_LOG
|
||||
;;
|
||||
restore)
|
||||
echo "${timestamp} ERROR:$PRODUCT restore failed" >> $STARTUP_LOG
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
kill $$
|
||||
exit 2
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user