feat(params): Use badparam func to manage logging

This commit is contained in:
2026-07-24 02:15:14 -06:00
parent 02e3e8d391
commit aebf8042e3
+2 -6
View File
@@ -47,7 +47,7 @@ badParam() {
elif [ "$1" = "errMsg" ]; then
printf "\n%sERROR: %s%s\n\n" "$err" "$2" "$norm"
([ "$logToConsole" -eq 0 ]) && writePlainTextLog \
"$2" "critical" "fail" "preexec" 1
"${2%%\Exit*}" "fatal" "fail" "preexec" 1
exit 1
fi
}
@@ -376,14 +376,10 @@ if ! command -v jq >/dev/null; then
fi
if [ -z "$dnsRecords" ]; then
badParam errMsg "You must specify at least one DNS record to update. Exiting."
([ "$logToConsole" -eq 0 ]) &&
writePlainTextLog "At least one DNS record to update must be specified" "fatal" "fail" "params" 1
fi
# verify the credentials file exists and is not empty (default check)
if [ ! -f "$accountFile" ] || [ ! -s "$accountFile" ]; then
badParam errMsg "Cannot find the Cloudflare credentials file (${accountFile}). Exiting."
([ "$logToConsole" -eq 0 ]) &&
writePlainTextLog "Cannot find the specified Cloudflare credentials file (${accountFile})" "fatal" "fail" "params" 1
badParam errMsg "Cannot find the Cloudflare credentials file (${accountFile}) or it is empty. Exiting."
fi
if [ "$logToJournal" -eq 1 ] && ! command -v logger >/dev/null 2>&1; then
printf "\n%sThis script requires 'logger' be installed to write entries to your journaling system. Exiting.%s\n\n" "$err" "$norm"