diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2019-09-23 16:55:09 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2019-11-27 23:42:52 -0500 |
commit | 9f140f700276574e937e89a9cc63682fb4bc2a20 (patch) | |
tree | 8d3fbcbbc6d9319c4bd54ecccfdb8aed0d3c0ffa | |
parent | 8375e8e21aa40c6bc4c4c816620ae40696ed929d (diff) |
proper error logging for IPC mechanism
-rwxr-xr-x | labs_change_detector | 4 | ||||
-rw-r--r-- | lib/send.sh | 4 | ||||
-rw-r--r-- | transport/transport_plus_ipc.sh.inc | 6 |
3 files changed, 8 insertions, 6 deletions
diff --git a/labs_change_detector b/labs_change_detector index c79b9f1..e272fb3 100755 --- a/labs_change_detector +++ b/labs_change_detector @@ -8,11 +8,11 @@ shopt -s extglob if ! which inotifywait &> /dev/null then - echo "[LABS]: ERROR: cannot find the \`inotify\` program" + log_error "[LABS]: ERROR: cannot find the \`inotify\` program" exit elif [[ ! -d "${BOT_MAIL_DIR}" ]] then - echo "[LABS]: no such directory set in BOT_MAIL_DIR: '${BOT_MAIL_DIR}'. fail" + log_error "[LABS]: ERROR: no such directory set in \$BOT_MAIL_DIR: '${BOT_MAIL_DIR}'" exit fi diff --git a/lib/send.sh b/lib/send.sh index 9cbe247..f9f653d 100644 --- a/lib/send.sh +++ b/lib/send.sh @@ -180,9 +180,9 @@ send_quit() { send_ipc_msg() { if [[ -z "${IPC_NOTICE_CHANNEL}" ]] - then echo '[SEND]: no target channel set in IPC_NOTICE_CHANNEL' + then log_error "[SEND]: ERROR: no target channel set in \$IPC_NOTICE_CHANNEL: '${IPC_NOTICE_CHANNEL}'" elif ! touch "${IPC_QUEUE_FILE}" 2> /dev/null - then echo "[SEND]: no such file set in IPC_QUEUE_FILE: '${IPC_QUEUE_FILE}'" + then log_error "[SEND]: ERROR: insufficient permissions on \$IPC_QUEUE_FILE: '${IPC_QUEUE_FILE}'" else local delay_secs=$1 ; shift ; local message=$* diff --git a/transport/transport_plus_ipc.sh.inc b/transport/transport_plus_ipc.sh.inc index 815061c..998f7c3 100644 --- a/transport/transport_plus_ipc.sh.inc +++ b/transport/transport_plus_ipc.sh.inc @@ -18,13 +18,15 @@ transport_plus_ipc_read_line() { local message="${BASH_REMATCH[3]}" local pending_line="${IPC_INJECT_PREFIX} ${target_channel} :${message}" + (( ${delivery_time} < $(date +%s) )) && line="${pending_line}" || line='' + # echo "[IPC]: delivery_time=${BASH_REMATCH[1]}" # echo "[IPC]: target_channel=${BASH_REMATCH[2]}" # echo "[IPC]: message=${BASH_REMATCH[3]}" # echo "[IPC]: pending_line=${IPC_INJECT_PREFIX} ${target_channel} :${message}" -(( ${delivery_time} < $(date +%s) )) && echo "[IPC]: relaying" # || echo "[IPC]: postponing" - (( ${delivery_time} < $(date +%s) )) && line="${pending_line}" || line='' + [[ -n "${line}" ]] && log_info "[IPC]: relaying to channel: ${target_channel} msg: ${message}" # || log_info "[IPC]: postponing" + else line='ERROR: invalid IPC message' fi |