style(RESTORE): add space before append redirects
This commit is contained in:
parent
ea0d98734a
commit
06df565348
@ -43,7 +43,7 @@ consoleError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exitError() {
|
exitError() {
|
||||||
printf "%s[%s] --- %s execution completed with error ---\n%s" "$err" "$(stamp)" "$scriptName" "$norm" >>"$logfile"
|
printf "%s[%s] --- %s execution completed with error ---\n%s" "$err" "$(stamp)" "$scriptName" "$norm" >> "$logfile"
|
||||||
exit "$1"
|
exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,30 +104,30 @@ textNewline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trapExit() {
|
trapExit() {
|
||||||
printf "%s[%s] -- [ERROR] 99: Caught signal --%s\n" "$err" "$(stamp)" "$norm" >>"$logfile"
|
printf "%s[%s] -- [ERROR] 99: Caught signal --%s\n" "$err" "$(stamp)" "$norm" >> "$logfile"
|
||||||
printf "%s[%s] --- %s execution terminated via signal ---\n%s" "$err" "$(stamp)" "$scriptName" "$norm" >>"$logfile"
|
printf "%s[%s] --- %s execution terminated via signal ---\n%s" "$err" "$(stamp)" "$scriptName" "$norm" >> "$logfile"
|
||||||
exit 99
|
exit 99
|
||||||
}
|
}
|
||||||
|
|
||||||
writeLog() {
|
writeLog() {
|
||||||
if [ "$1" = "task" ]; then
|
if [ "$1" = "task" ]; then
|
||||||
printf "%s[%s] -- [INFO] %s... " "$info" "$(stamp)" "$2" >>"$logfile"
|
printf "%s[%s] -- [INFO] %s... " "$info" "$(stamp)" "$2" >> "$logfile"
|
||||||
elif [ "$1" = "done" ]; then
|
elif [ "$1" = "done" ]; then
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
printf "%sdone%s --\n%s" "$ok" "$info" "$norm" >>"$logfile"
|
printf "%sdone%s --\n%s" "$ok" "$info" "$norm" >> "$logfile"
|
||||||
elif [ "$2" = "error" ]; then
|
elif [ "$2" = "error" ]; then
|
||||||
printf "%sERROR%s --\n%s" "$err" "$info" "$norm" >>"$logfile"
|
printf "%sERROR%s --\n%s" "$err" "$info" "$norm" >> "$logfile"
|
||||||
elif [ "$2" = "warn" ]; then
|
elif [ "$2" = "warn" ]; then
|
||||||
printf "%swarning%s --\n%s" "$yellow" "$info" "$norm" >>"$logfile"
|
printf "%swarning%s --\n%s" "$yellow" "$info" "$norm" >> "$logfile"
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "error" ]; then
|
elif [ "$1" = "error" ]; then
|
||||||
printf "%s[%s] -- [ERROR] %s: %s --\n%s" "$err" "$(stamp)" "$2" "$3" "$norm" >>"$logfile"
|
printf "%s[%s] -- [ERROR] %s: %s --\n%s" "$err" "$(stamp)" "$2" "$3" "$norm" >> "$logfile"
|
||||||
elif [ "$1" = "warn" ]; then
|
elif [ "$1" = "warn" ]; then
|
||||||
printf "%s[%s] -- [WARNING] %s --\n%s" "$yellow" "$(stamp)" "$2" "$norm" >>"$logfile"
|
printf "%s[%s] -- [WARNING] %s --\n%s" "$yellow" "$(stamp)" "$2" "$norm" >> "$logfile"
|
||||||
elif [ "$1" = "info" ]; then
|
elif [ "$1" = "info" ]; then
|
||||||
printf "%s[%s] -- [INFO] %s --\n%s" "$info" "$(stamp)" "$2" "$norm" >>"$logfile"
|
printf "%s[%s] -- [INFO] %s --\n%s" "$info" "$(stamp)" "$2" "$norm" >> "$logfile"
|
||||||
elif [ "$1" = "success" ]; then
|
elif [ "$1" = "success" ]; then
|
||||||
printf "%s[%s] -- [SUCCESS] %s --\n%s" "$ok" "$(stamp)" "$2" "$norm" >>"$logfile"
|
printf "%s[%s] -- [SUCCESS] %s --\n%s" "$ok" "$(stamp)" "$2" "$norm" >> "$logfile"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# write initial log entries
|
# write initial log entries
|
||||||
if ! printf "%s[%s] --- Start %s execution ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" 2>/dev/null >>"$logfile"; then
|
if ! printf "%s[%s] --- Start %s execution ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" 2>/dev/null >> "$logfile"; then
|
||||||
consoleError '1' "Unable to write to log file ($logfile)"
|
consoleError '1' "Unable to write to log file ($logfile)"
|
||||||
fi
|
fi
|
||||||
writeLog 'info' "Log located at $logfile"
|
writeLog 'info' "Log located at $logfile"
|
||||||
@ -562,14 +562,14 @@ fi
|
|||||||
### exit gracefully
|
### exit gracefully
|
||||||
if [ "$errorCount" -gt 0 ]; then
|
if [ "$errorCount" -gt 0 ]; then
|
||||||
# note non-terminating errors
|
# note non-terminating errors
|
||||||
printf "%s[%s] --- %s execution completed with %s error(s) ---\n%s" "$err" "$(stamp)" "$scriptName" "$errorCount" "$norm" >>"$logfile"
|
printf "%s[%s] --- %s execution completed with %s error(s) ---\n%s" "$err" "$(stamp)" "$scriptName" "$errorCount" "$norm" >> "$logfile"
|
||||||
exit 98
|
exit 98
|
||||||
elif [ "$warnCount" -gt 0 ]; then
|
elif [ "$warnCount" -gt 0 ]; then
|
||||||
printf "%s[%s] --- %s execution completed with %s warning(s) ---\n%s" "$yellow" "$(stamp)" "$scriptName" "$warnCount" "$norm" >>"$logfile"
|
printf "%s[%s] --- %s execution completed with %s warning(s) ---\n%s" "$yellow" "$(stamp)" "$scriptName" "$warnCount" "$norm" >> "$logfile"
|
||||||
exit 97
|
exit 97
|
||||||
else
|
else
|
||||||
writeLog 'success' "All processes completed"
|
writeLog 'success' "All processes completed"
|
||||||
printf "%s[%s] --- %s execution completed ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" >>"$logfile"
|
printf "%s[%s] --- %s execution completed ---\n%s" "$magenta" "$(stamp)" "$scriptName" "$norm" >> "$logfile"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user