feature(BACKUP): parameterize log colourization

Closes github #9
This commit is contained in:
Asif Bacchus 2021-03-07 23:54:32 -07:00
parent 16f4c11f91
commit de76918e81

View File

@ -164,6 +164,10 @@ scriptHelp() {
textblock "Path to write log file" textblock "Path to write log file"
defaultsTextblock "(scriptPath/scriptName.log)" defaultsTextblock "(scriptPath/scriptName.log)"
newline newline
switchTextblock "[SWITCH] --nc | --no-color | --no-colour"
textblock "Do NOT use ANSI colourization in the log file (in case your preferred log viewer does not support it)."
defaultsTextblock "(use ANSI colourization to make log file look good)"
newline
switchTextblock "--compression" switchTextblock "--compression"
textblock "Compression algorithm(s) that borg should use. Please run 'borg help compression' for details." textblock "Compression algorithm(s) that borg should use. Please run 'borg help compression' for details."
defaultsTextblock "(not specified, use borg default of lz4)" defaultsTextblock "(not specified, use borg default of lz4)"
@ -252,6 +256,7 @@ trapExit() {
scriptPath="$( CDPATH='' cd -- "$( dirname -- "$0" )" && pwd -P )" scriptPath="$( CDPATH='' cd -- "$( dirname -- "$0" )" && pwd -P )"
scriptName="$( basename "$0" )" scriptName="$( basename "$0" )"
logFile="$scriptPath/${scriptName%.*}.log" logFile="$scriptPath/${scriptName%.*}.log"
colourizeLogFile=1
warnCount=0 warnCount=0
configDetails="$scriptPath/${scriptName%.*}.details" configDetails="$scriptPath/${scriptName%.*}.details"
err503Copied=0 err503Copied=0
@ -291,6 +296,10 @@ while [ $# -gt 0 ]; do
badParam empty "$@" badParam empty "$@"
fi fi
;; ;;
--nc|--no-color|--no-colour)
# do NOT colourize log file
colourizeLogFile=0
;;
-c|--config|--details) -c|--config|--details)
# location of config details file # location of config details file
if [ -n "$2" ]; then if [ -n "$2" ]; then
@ -436,6 +445,17 @@ fi
if [ -n "$borgCompression" ]; then if [ -n "$borgCompression" ]; then
borgCreateParams="${borgCreateParams} --compression ${borgCompression}" borgCreateParams="${borgCreateParams} --compression ${borgCompression}"
fi fi
# remove colourization if parameter specified
if [ "$colourizeLogFile" -eq 0 ]; then
bold=""
cyan=""
err=""
magenta=""
norm=""
ok=""
warn=""
yellow=""
fi
### read mailcow.conf and set vars as needed ### read mailcow.conf and set vars as needed
# shellcheck source=./mailcow.conf.shellcheck # shellcheck source=./mailcow.conf.shellcheck