Changed warning and error exit reports to incorporate timestamps

This commit is contained in:
Asif Bacchus 2018-10-22 05:46:35 -06:00
parent deacdcd04e
commit d6f48908b5

View File

@ -105,11 +105,14 @@ function scriptHelp {
function quit {
# list generated warnings, if any
if [ ${#exitWarn[@]} -gt 0 ]; then
echo -e "${warn}${scriptName} generated the following warnings:" \
echo -e "\n${warn}${scriptName} generated the following warnings:" \
"${normal}" >> "$logFile"
for warnCode in "${exitWarn[@]}"; do
echo -e "${warn}-- [WARNING] ${warningExplain[$warnCode]}" \
"(code: ${warnCode}) --${normal}" >> "$logFile"
warnStamp="${warnCode%%_*}"
warnValue="${warnCode##*_}"
echo -e "${warn}${warnStamp} -- [WARNING]" \
"${warningExplain[$warnValue]} (code: ${warnValue}) --" \
"${normal}" >> "$logFile"
done
fi
if [ -z "${exitError}" ]; then
@ -119,11 +122,13 @@ function quit {
exit 0
else
# list generated errors and explanations then exit script with code 2
echo -e "${err}${scriptName} generated the following errors:" \
echo -e "\n${err}${scriptName} generated the following errors:" \
"${normal}" >> "$logFile"
for errCode in "${exitError[@]}"; do
echo -e "${err}-- [ERROR] ${errorExplain[$errCode]}" \
"(code: ${errCode}) --$normal" >> "$logFile"
errStamp="${errCode%%_*}"
errValue="${errCode##*_}"
echo -e "${err}${errStamp} -- [ERROR] ${errorExplain[$errValue]}" \
"(code: ${errValue}) --${normal}" >> "$logFile"
done
exit 2
fi