From d6f48908b54dd770a95d3af0c59371e7d1aa501f Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 22 Oct 2018 05:46:35 -0600 Subject: [PATCH] Changed warning and error exit reports to incorporate timestamps --- root/scripts/backup.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/root/scripts/backup.sh b/root/scripts/backup.sh index 202c28e..019f341 100644 --- a/root/scripts/backup.sh +++ b/root/scripts/backup.sh @@ -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