From: Daniel F. Dickinson Date: Sat, 18 Jul 2026 22:49:27 +0000 (-0400) Subject: nut: add process id to log messages X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=7a76011672de559cbabceb9672aca59a9ffb4205;p=openwrt-packages.git nut: add process id to log messages Show the PID beside the syslog_id to aid debugging. Signed-off-by: Daniel F. Dickinson --- diff --git a/net/nut/files/libhid-ups.hotplug b/net/nut/files/libhid-ups.hotplug index 93ec81ec0..0400b28b7 100644 --- a/net/nut/files/libhid-ups.hotplug +++ b/net/nut/files/libhid-ups.hotplug @@ -16,7 +16,7 @@ # shellcheck source=net/nut/files/functions.sh.functions . "${IPKG_INSTROOT}"/lib/functions.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-usb-hotplug "Unable to source 'functions.sh' in 'libhid-ups' hotplug. Bailing" + logger -t nut-usb-hotplug[$$] "Unable to source 'functions.sh' in 'libhid-ups' hotplug. Bailing" exit 1 } @@ -26,7 +26,7 @@ # shellcheck source=net/nut/files/nut-common.sh.functions . "${IPKG_INSTROOT}"/lib/functions/nut/nut-common.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-usb-hotplug "Unable to source 'nut-common.sh' in 'libhid-ups' hotplug. Bailing" + logger -t nut-usb-hotplug[$$] "Unable to source 'nut-common.sh' in 'libhid-ups' hotplug. Bailing" exit 1 } diff --git a/net/nut/files/nut-cgi.init b/net/nut/files/nut-cgi.init index f7e256a2f..9cd65089d 100644 --- a/net/nut/files/nut-cgi.init +++ b/net/nut/files/nut-cgi.init @@ -35,7 +35,7 @@ UPSCGI_HOSTS_CONF="${UPSCGI_CONF_DIR}/hosts.conf" # shellcheck source=net/nut/files/functions.sh.functions . "${IPKG_INSTROOT}"/lib/functions.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-cgi "Unable to source 'functions.sh'" + logger -t nut-cgi[$$] "Unable to source 'functions.sh'" exit 1 } @@ -45,7 +45,7 @@ UPSCGI_HOSTS_CONF="${UPSCGI_CONF_DIR}/hosts.conf" # shellcheck source=net/nut/files/nut-common.sh.functions . "${IPKG_INSTROOT}"/lib/functions/nut/nut-common.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-cgi "Failed to load nut-common.sh" + logger -t nut-cgi[$$] "Failed to load nut-common.sh" exit 1 } diff --git a/net/nut/files/nut-common.sh.functions b/net/nut/files/nut-common.sh.functions index 1b8a2a26f..258e9861e 100644 --- a/net/nut/files/nut-common.sh.functions +++ b/net/nut/files/nut-common.sh.functions @@ -185,7 +185,7 @@ log_msg() { local level="${4:-notice}" local facility="${5:-daemon}" - logger -t "$syslog_id" -p "${facility}.${level}" "'$reason' in '$current_script'" || { + logger -t "${syslog_id}[$$]" -p "${facility}.${level}" "'$reason' in '$current_script'" || { # We use 'tr' as changing case via variable parameter substitution is not available in ash on OpenWrt # shellcheck disable=SC2018,SC2019 level="$(echo "$level" | tr 'a-z' 'A-Z')" diff --git a/net/nut/files/nut-monitor.init b/net/nut/files/nut-monitor.init index ae2830337..eb4f80ad9 100644 --- a/net/nut/files/nut-monitor.init +++ b/net/nut/files/nut-monitor.init @@ -18,7 +18,7 @@ USE_PROCD=1 # shellcheck source=net/nut/files/functions.sh.functions . "${IPKG_INSTROOT}"/lib/functions.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-monitor "Unable to source 'functions.sh' in 'nut-monitor'. Bailing" + logger -t nut-monitor[$$] "Unable to source 'functions.sh' in 'nut-monitor'. Bailing" exit 1 } @@ -28,7 +28,7 @@ USE_PROCD=1 # shellcheck source=net/nut/files/nut-common.sh.functions . "${IPKG_INSTROOT}"/lib/functions/nut/nut-common.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-monitor "Unable to source 'nut-common.sh' in 'nut-monitor'. Bailing" + logger -t nut-monitor[$$] "Unable to source 'nut-common.sh' in 'nut-monitor'. Bailing" exit 1 } diff --git a/net/nut/files/nut-sendmail-notify b/net/nut/files/nut-sendmail-notify index b49de4bde..cd26c1ed4 100644 --- a/net/nut/files/nut-sendmail-notify +++ b/net/nut/files/nut-sendmail-notify @@ -15,7 +15,7 @@ # shellcheck source=net/nut/files/functions.sh.functions . "${IPKG_INSTROOT}"/lib/functions.sh || { - logger -t nut-sendmail-notify "Unable to source 'functions.sh' in 'nut-sendmail-notify'. Bailing" + logger -t nut-sendmail-notify[$$] "Unable to source 'functions.sh' in 'nut-sendmail-notify'. Bailing" exit 1 } @@ -24,7 +24,7 @@ # shellcheck disable=SC1094 # shellcheck source=net/nut/files/nut-common.sh.functions . "${IPKG_INSTROOT}"/lib/functions/nut/nut-common.sh || { - logger -t nut-sendmail-notify "Unable to source 'nut-common.sh' in 'nut-sendmail-notify'. Bailing" + logger -t nut-sendmail-notify[$$] "Unable to source 'nut-common.sh' in 'nut-sendmail-notify'. Bailing" exit 1 } @@ -33,7 +33,7 @@ log_send_failure_and_exit() { local reason="$1" local syslog_id="nut-sendmail-notify" local message_prefix="Message was not sent" - logger -t "$syslog_id" "${message_prefix}: $reason" || { + logger -t "${syslog_id}[$$]" "${message_prefix}: $reason" || { printf "%s: %s: %s, and logging failed\n" "$syslog_id" "$message_prefix" "$reason" >&2 } exit 1 diff --git a/net/nut/files/nut-serial.hotplug b/net/nut/files/nut-serial.hotplug index 3669a0c5c..9da375df8 100644 --- a/net/nut/files/nut-serial.hotplug +++ b/net/nut/files/nut-serial.hotplug @@ -16,7 +16,7 @@ # shellcheck source=net/nut/files/functions.sh.functions . "${IPKG_INSTROOT}"/lib/functions.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-serial-hotplug "Unable to source 'functions.sh' in 'nut-serial' hotplug. Bailing" + logger -t nut-serial-hotplug[$$] "Unable to source 'functions.sh' in 'nut-serial' hotplug. Bailing" exit 1 } @@ -26,7 +26,7 @@ # shellcheck source=net/nut/files/nut-common.sh.functions . "${IPKG_INSTROOT}"/lib/functions/nut/nut-common.sh || { # Before our sourcing error logging definitions are sourced - logger -t nut-serial-hotplug "Unable to source 'nut-common.sh' in 'nut-serial' hotplug. Bailing" + logger -t nut-serial-hotplug[$$] "Unable to source 'nut-common.sh' in 'nut-serial' hotplug. Bailing" exit 1 } diff --git a/net/nut/files/nut-server.init b/net/nut/files/nut-server.init index 5b6d35f79..8a80d2ede 100644 --- a/net/nut/files/nut-server.init +++ b/net/nut/files/nut-server.init @@ -29,7 +29,7 @@ USE_PROCD=1 # shellcheck source=net/nut/files/functions.sh.functions . "${IPKG_INSTROOT}"/lib/functions.sh || { # Before our sourcing error logging definitions are sourced - logger -t "nut-server" "FATAL: Unable to source 'functions.sh' in 'nut-server'" + logger -t "nut-server[$$]" "FATAL: Unable to source 'functions.sh' in 'nut-server'" exit 1 } @@ -39,7 +39,7 @@ USE_PROCD=1 # shellcheck source=net/nut/files/nut-common.sh.functions . "${IPKG_INSTROOT}"/lib/functions/nut/nut-common.sh || { # Before our sourcing error logging definitions are sourced - logger -t "nut-server" "FATAL: Unable to source 'nut-common.sh' in 'nut-server'" + logger -t "nut-server[$$]" "FATAL: Unable to source 'nut-common.sh' in 'nut-server'" exit 1 } @@ -397,7 +397,7 @@ reload_ups_driver() { stop_service_if_no_instances() { if service_active_no_instances "nut-server"; then - logger -s -t "nut-server" "nut-server active with no instances" + logger -t "nut-server" "nut-server active with no instances" # If "nut-server" is active with no instances # We don't care about the exit code of procd_kill, and logging its # stderr can aid debugging.