feat(params): Add log type, fmt params

Add log type and format parameters. Update defaults. Update help script.
This commit is contained in:
2026-07-24 01:03:28 -06:00
parent 1732de343d
commit c792ec8a0a
+38 -26
View File
@@ -153,34 +153,38 @@ scriptHelp() {
textBlock "The only required parameter is '--records' which is a comma-delimited list of hostnames to update. However, there are several other options which may be useful to implement." textBlock "The only required parameter is '--records' which is a comma-delimited list of hostnames to update. However, there are several other options which may be useful to implement."
textBlock "Parameters are listed below and followed by a description of their effect. If a default value exists, it will be listed on the following line in (parentheses)." textBlock "Parameters are listed below and followed by a description of their effect. If a default value exists, it will be listed on the following line in (parentheses)."
newline newline
textBlock "${magenta}--- script related parameters ---${norm}" textBlock "${magenta}--- script-related parameters ---${norm}"
newline newline
textBlockSwitches "-c | --cred | --creds | --credentials | -f (deprecated, backward-compatibility)" textBlockSwitches "-c | --cred | --creds | --credentials | -f (deprecated, backward-compatibility)"
textBlock "Path to file containing your Cloudflare *token* credentials. Please refer to the repo README for more information on format, etc." textBlock "Path to the file containing your Cloudflare *token* credentials. Please refer to the repo README for more information on format, etc."
textBlockDefaults "(${accountFile})" textBlockDefaults "(${accountFile})"
newline newline
textBlockSwitches "-l | --log" textBlockSwitches "--log-file"
textBlock "Path where the log file should be written." textBlock "Path where the log file should be written. Script will use file-based logging."
textBlockDefaults "(${logFile})" textBlockDefaults "(${logFile})"
newline newline
textBlockSwitches "--nc | --no-color | --no-colour"
textBlock "Switch value. Disables ANSI colours in the log. Useful if you review the logs using a reader that does not parse ANSI colour codes."
textBlockDefaults "(disabled: print logs in colour)"
newline
textBlockSwitches "--log-console" textBlockSwitches "--log-console"
textBlock "Switch value. Output log to console (stdout) instead of a log file. Can be combined with --nc if desired." textBlock "Switch value. Script will use console-based (stdout) logging."
textBlockDefaults "(disabled: output to log file)" textBlockDefaults "(disabled: use file-based logging)"
newline newline
textBlockSwitches "--log-journal" textBlockSwitches "--log-journal"
textBlock "Switch value. Output a structured log entry to your journaling system instead of a log file. Implies --nc." textBlock "Switch value. Script will use journald-based logging."
textBlockDefaults "(disabled: output to log file)" textBlockDefaults "(disabled: use file-based logging)"
newline newline
textBlockSwitches "--no-log" textBlockSwitches "--log-none"
textBlock "Switch value. Do not create a log (i.e. no console, no file). You will not have *any* output from the script if you choose this option, so you will not know if updates succeeded or failed." textBlock "Switch value. Script will not log anything. You will not have *any* output from the script if you choose this option, so you will not know if updates succeed or fail."
textBlockDefaults "(disabled: output to log file)" textBlockDefaults "(disabled: use file-based logging)"
newline
textBlockSwitches "--fmt-json"
textBlock "Switch value. Use JSON formatted key-value pair structured logging format. Best when using a log parsing tool or log management system to read your log files. Does not apply when using '--log-journal'."
textBlockDefaults "(enabled)"
newline
textBlockSwitches "--fmt-syslog"
textBlock "Switch value. Use a modified syslog (plain-text) format for log messages. Ideal when logging to the console. Does not apply when using '--log-journal'."
textBlockDefaults "(disabled: use structured JSON logging)"
newline newline
textBlockSwitches "-h | --help | -?" textBlockSwitches "-h | --help | -?"
textBlock "Display this help screen." textBlock "Display this information screen."
newline newline
textBlockSwitches "--examples" textBlockSwitches "--examples"
textBlock "Show some usage examples." textBlock "Show some usage examples."
@@ -191,7 +195,7 @@ scriptHelp() {
textBlock "Comma-delimited list of hostnames for which IP addresses should be updated in Cloudflare DNS. This parameter is REQUIRED. Note that this script will only *update* records, it will not create new ones. If you supply hostnames that are not already defined in DNS, the script will log a warning and will skip those hostnames." textBlock "Comma-delimited list of hostnames for which IP addresses should be updated in Cloudflare DNS. This parameter is REQUIRED. Note that this script will only *update* records, it will not create new ones. If you supply hostnames that are not already defined in DNS, the script will log a warning and will skip those hostnames."
newline newline
textBlockSwitches "-i | --ip | --ip-address | -a | --address" textBlockSwitches "-i | --ip | --ip-address | -a | --address"
textBlock "New IP address for DNS host records. If you omit this, the script will attempt to auto-detect your public IP address and use that." textBlock "New IP address for DNS host records. If you omit this, the script will attempt to auto-detect your public IP address and use that. N.B. IP addresses are *not* parsed for correctness."
newline newline
textBlockSwitches "-4 | --ip4 | --ipv4" textBlockSwitches "-4 | --ip4 | --ipv4"
textBlock "Switch value. Update Host 'A' records (IP4) only. Note that this script can only update either A *or* AAAA records. If you need to update both, you'll have to run the script once in IP4 mode and again in IP6 mode. If you specify both this switch and the IP6 switch, the last one specified will take effect." textBlock "Switch value. Update Host 'A' records (IP4) only. Note that this script can only update either A *or* AAAA records. If you need to update both, you'll have to run the script once in IP4 mode and again in IP6 mode. If you specify both this switch and the IP6 switch, the last one specified will take effect."
@@ -227,6 +231,8 @@ scriptPath="$(CDPATH='' \cd -- "$(dirname -- "$0")" && pwd -P)"
scriptName="$(basename "$0")" scriptName="$(basename "$0")"
logFile="$scriptPath/${scriptName%.*}.log" logFile="$scriptPath/${scriptName%.*}.log"
logToJournal=0 logToJournal=0
useJsonLogFmt=1
useSyslogLogFmt=0
accountFile="$scriptPath/cloudflare.credentials" accountFile="$scriptPath/cloudflare.credentials"
colourizeLogFile=1 colourizeLogFile=1
dnsRecords="" dnsRecords=""
@@ -253,8 +259,8 @@ while [ $# -gt 0 ]; do
# display sample commands # display sample commands
scriptExamples scriptExamples
;; ;;
-l | --log) --log-file)
# set log file location # use file-based logging at the specified location
if [ -n "$2" ]; then if [ -n "$2" ]; then
logFile="${2%/}" logFile="${2%/}"
shift shift
@@ -263,23 +269,29 @@ while [ $# -gt 0 ]; do
fi fi
;; ;;
--log-console) --log-console)
# log to the console instead of a file # use console-based logging
logFile="/dev/stdout" logFile="/dev/stdout"
;; ;;
--log-journal) --log-journal)
# log to the journal system instead of a file # use journald-based logging
logToJournal=1 logToJournal=1
;; ;;
--no-log) --log-none)
# do not log anything # do not log anything
logFile="/dev/null" logFile="/dev/null"
;; ;;
--nc | --no-color | --no-colour) --fmt-json)
# do not colourize log file # use JSON log formatting
colourizeLogFile=0 useJsonLogFmt=1
useSyslogLogFmt=0
;;
--fmt-syslog)
# use modified syslog plain-text log formatting
useSyslogLogFmt=1
useJsonLogFmt=0
;; ;;
-c | --cred* | -f) -c | --cred* | -f)
# path to Cloudflare credentials file # path to the Cloudflare credentials file
if [ -n "$2" ]; then if [ -n "$2" ]; then
if [ -f "$2" ] && [ -s "$2" ]; then if [ -f "$2" ] && [ -s "$2" ]; then
accountFile="${2%/}" accountFile="${2%/}"