Add debugging support. Bump version.

This commit is contained in:
Darren 'Tadgy' Austin 2021-09-21 19:36:56 +01:00
commit daeb67a334

View file

@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2018-2020:
# Copyright (c) 2018-2021:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3.
#
@ -8,7 +8,7 @@
# Script details.
NAME="${0##*/}"
VERSION="0.3.1"
VERSION="0.3.2"
# Functions.
@ -67,6 +67,7 @@ create_missing_dirs() {
die() {
# $1 The text of the error message to display on stderr.
(( DEBUG == 1 )) && printf "%s: %s: %s\\n" "$(date "+%Y%m%d %H%M%S.%N")" "die" "$1" >>"$DEBUG_FILE"
printf "%s: %s\\n" "$NAME" "$1" >&2
exit 1
}
@ -314,6 +315,7 @@ syslog() {
[[ -z "$1" || -z "$2" ]] && return 1
(( DEBUG == 1 )) && printf "%s: %s: %s: %s\\n" "$(date "+%Y%m%d %H%M%S.%N")" "syslog" "$1" "$2" >>"$DEBUG_FILE"
logger --id="$$" -p "$SYSLOG_FACILITY.$1" -t "$NAME" "$1: $2" 2>/dev/null
}
@ -572,7 +574,7 @@ while :; do
start_compression_jobs
# If debugging is enabled, record the time of entry into the read below.
(( DEBUG == 1 )) && printf "%s - %s\n" "$(date "+%Y%m%d %H%M%S.%N")" "Enter read" >>"$DEBUG_FILE"
(( DEBUG == 1 )) && printf "%s: %s\\n" "$(date "+%Y%m%d %H%M%S.%N")" "enter read" >>"$DEBUG_FILE"
# Read the log line, but timeout at the top of the next second if nothing is read.
# Note: The second $(...) expansion should *not* be quoted in this instance, and
@ -582,7 +584,7 @@ while :; do
ERR="$?"
# If debugging, record the time of exit from read.
(( DEBUG == 1 )) && printf "%s - %s\n" "$(date "+%Y%m%d %H%M%S.%N")" "Exit read: ERR = $ERR, VHOST = $LOG_VHOST DATA = ${LOG_DATA:0:50}" >>"$DEBUG_FILE"
(( DEBUG == 1 )) && printf "%s: %s: ERR=%s, VHOST=%s, DATA=%s\\n" "$(date "+%Y%m%d %H%M%S.%N")" "exit read" "$ERR" "$LOG_VHOST" "${LOG_DATA:0:50}" >>"$DEBUG_FILE"
# Determine how the read above was exited.
if (( ERR > 128 )); then