Skip to content

Commit

Permalink
Fixed logging.sh so it would not try to write log messages to non-exi…
Browse files Browse the repository at this point in the history
…stent log files (e.g., scenario.log when a scenario is not in progress).
  • Loading branch information
jasonfleming committed May 31, 2019
1 parent e796a7a commit 207467c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions config/tests/asgs_config_nam_swan_queenbee_ec95d.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# etc)
#-------------------------------------------------------------------
#
# Copyright(C) 2016--2018 Jason Fleming
# Copyright(C) 2016--2019 Jason Fleming
#
# This file is part of the ADCIRC Surge Guidance System (ASGS).
#
Expand Down Expand Up @@ -38,7 +38,7 @@ REINITIALIZESWAN=no # used to bounce the wave solution

ADCIRCDIR=~/adcirc-cg/jasonfleming/v53release/work # ADCIRC executables
SWANDIR=~/adcirc-cg/jasonfleming/v53release/swan # SWAN executables
SCRIPTDIR=~/asgs/jasonfleming/portability # ASGS executables
SCRIPTDIR=~/asgs/jasonfleming/master # ASGS executables
INPUTDIR=$SCRIPTDIR/input/meshes/ec95d # grid and other input files
OUTPUTDIR=${SCRIPTDIR}/output # post processing scripts
PERL5LIB=${SCRIPTDIR}/PERL # DateCale.pm perl module
Expand Down
32 changes: 21 additions & 11 deletions monitoring/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,18 @@ logMessage()
cycleMessage()
{ DATETIME=`date +'%Y-%h-%d-T%H:%M:%S%z'`
MSG="[${DATETIME}] INFO: $@"
echo ${MSG} >> $ADVISDIR/cycle.log
if [[ -e $ADVISDIR/cycle.log ]]; then
echo ${MSG} >> $ADVISDIR/cycle.log
fi
}
#
# write an INFO-level message to the cycle (or advisory log file)
scenarioMessage()
{ DATETIME=`date +'%Y-%h-%d-T%H:%M:%S%z'`
MSG="[${DATETIME}] INFO: $@"
echo ${MSG} >> $ADVISDIR/$ENSTORM/scenario.log
if [[ -e $ADVISDIR/$ENSTORM/scenario.log ]]; then
echo ${MSG} >> $ADVISDIR/$ENSTORM/scenario.log
fi
}

#
Expand All @@ -257,20 +261,24 @@ allMessage()
warn()
{ DATETIME=`date +'%Y-%h-%d-T%H:%M:%S%z'`
MSG="[${DATETIME}] WARNING: $@"
echo ${MSG} >> ${SYSLOG}
echo ${MSG} >> $ADVISDIR/cycle.log
echo ${MSG} >> $ADVISDIR/$ENSTORM/scenario.log
for file in $SYSLOG $ADVISDIR/cycle.log $ADVISDIR/$ENSTORM/scenario.log ; do
if [[ -e $file ]]; then
echo ${MSG} >> ${SYSLOG}
fi
done
#echo ${MSG} # send to console
}
#
# log an error message, notify Operator
error()
{ DATETIME=`date +'%Y-%h-%d-T%H:%M:%S%z'`
MSG="[${DATETIME}] ERROR: $@"
echo ${MSG} >> ${SYSLOG}
echo ${MSG} # send to console
echo ${MSG} >> $ADVISDIR/cycle.log
echo ${MSG} >> $ADVISDIR/$ENSTORM/scenario.log
for file in $SYSLOG $ADVISDIR/cycle.log $ADVISDIR/$ENSTORM/scenario.log ; do
if [[ -e $file ]]; then
echo ${MSG} >> ${SYSLOG}
fi
done
# email the operator
if [[ $EMAILNOTIFY = yes || $EMAILNOTIFY = YES ]]; then
echo $MSG | mail -s "[ASGS] Attn: Error for $INSTANCENAME" "${ASGSADMIN}"
Expand All @@ -281,9 +289,11 @@ error()
fatal()
{ DATETIME=`date +'%Y-%h-%d-T%H:%M:%S%z'`
MSG="[${DATETIME}] FATAL ERROR: $@"
echo ${MSG} >> ${SYSLOG}
echo ${MSG} >> $ADVISDIR/cycle.log
echo ${MSG} >> $ADVISDIR/$ENSTORM/scenario.log
for file in $SYSLOG $ADVISDIR/cycle.log $ADVISDIR/$ENSTORM/scenario.log ; do
if [[ -e $file ]]; then
echo ${MSG} >> ${SYSLOG}
fi
done
if [[ $EMAILNOTIFY = yes || $EMAILNOTIFY = YES ]]; then
cat ${SYSLOG} | mail -s "[ASGS] Fatal Error for PROCID ($$)" "${ASGSADMIN}"
fi
Expand Down

0 comments on commit 207467c

Please sign in to comment.