From: Daniel F. Dickinson Date: Sat, 18 Jul 2026 22:51:35 +0000 (-0400) Subject: nut: use common log functions instead of direct logger calls X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=a9f0e9fae4c33094a51a190ff06f6ea26acfbd92;p=openwrt-packages.git nut: use common log functions instead of direct logger calls Where possible prefer the log wrappers to direct logger calls. Signed-off-by: Daniel F. Dickinson --- diff --git a/net/nut/files/libhid-ups.hotplug b/net/nut/files/libhid-ups.hotplug index 0400b28b7..babbff17a 100644 --- a/net/nut/files/libhid-ups.hotplug +++ b/net/nut/files/libhid-ups.hotplug @@ -58,7 +58,7 @@ start_stop_driver() { add) # Skip hotplug if it is disabled or NUT is shutting down if ! allow_hotplug_restart; then - logger -s -t nut-usb-hotplug "Hotplug restart disabled starting '$ups' when processing '$ACTION' for '$DEVNAME'" + log_msg "Hotplug restart disabled starting '$ups' when processing '$ACTION' for '$DEVNAME'" "libhid-ups" nut-usb-hotplug info # This is a configuration not an error return 0 fi @@ -66,7 +66,7 @@ start_stop_driver() { # Set permissions to allow the UPS device to start # In some cases this may be enough for the UPS to start working if ! ensure_usb_ups_access "$ups" "$known_devname"; then - logger -s -t nut-usb-hotplug "Unable to enable access to '$ups' when processing '$ACTION' for '$DEVNAME'" + log_error "Unable to enable access to '$ups' when processing '$ACTION' for '$DEVNAME'" "libhid-ups" nut-usb-hotplug return 0 fi @@ -77,11 +77,11 @@ start_stop_driver() { # our last check. if /etc/init.d/nut-server enabled; then if ! /etc/init.d/nut-server start "$ups"; then - logger -s -t nut-usb-hotplug "Failed to start '$ups' processing '$ACTION' for '$DEVNAME'" + log_error "Failed to start '$ups' processing '$ACTION' for '$DEVNAME'" "libhid-ups" nut-usb-hotplug return 0 fi else - logger -s -t nut-usb-hotplug "Hotplug became disabled while processing '$ACTION' for '$DEVNAME'." + log_error "Hotplug became disabled while processing '$ACTION' for '$DEVNAME'." "libhid-ups" nut-usb-hotplug return 0 fi ;; @@ -90,7 +90,7 @@ start_stop_driver() { # We stop only the removed UPS as we want the NUT service and other # UPS (if any) to remain up. /etc/init.d/nut-server stop "$ups" || { - logger -s -t nut-usb-hotplug "Failed to stop nut-driver instance (UPS) '$ups'." + log_error "Failed to stop nut-driver instance (UPS) '$ups'." "libhid-ups" nut-usb-hotplug return 0 } ;; @@ -116,7 +116,7 @@ nut_driver_config() { # we keep going as we will restart this UPS with no match. config_get cfg_vendorid "$ups" vendorid if [ -n "$cfg_vendorid" ] && ! check_valid_hex_number "${cfg_vendorid/0x/}"; then - logger -s -t nut-usb-hotplug "Configured vendorid for '$ups' is not valid" + log_error "Configured vendorid for '$ups' is not valid" "libhid-ups" nut-usb-hotplug nd_driver_config_error=true return 0 fi @@ -138,7 +138,7 @@ nut_driver_config() { # we keep going as we will restart this UPS with no match. config_get cfg_productid "$ups" productid if [ -n "$cfg_productid" ] && ! check_valid_hex_number "${cfg_productid/0x/}"; then - logger -s -t nut-usb-hotplug "Configured productid for '$ups' is not valid" + log_error "Configured productid for '$ups' is not valid" "libhid-ups" nut-usb-hotplug nd_driver_config_error=true return 0 fi @@ -163,7 +163,7 @@ nut_driver_config() { if [ "$try_match" = "no" ]; then if [ "$ACTION" = "add" ]; then if ! allow_hotplug_restart; then - logger -s -t nut-usb-hotplug "Hotplug restart disabled starting '$ups' when processing '$ACTION' for '$DEVNAME'" + log_msg "Hotplug restart disabled starting '$ups' when processing '$ACTION' for '$DEVNAME'" "libhid-ups" nut-usb-hotplug notice return 0 fi # We check enabled again here, in case of a race condition since @@ -173,14 +173,14 @@ nut_driver_config() { # than restart of '$ups'. The nut-server initscript will do a # start if the reload fails. /etc/init.d/nut-server reload "$ups" || { - log_error "Failed to reload unmatched driver instance (UPS) '$ups' in nut_driver_config" libhid-ups nut-usb-hotplug + log_msg "Failed to reload unmatched driver instance (UPS) '$ups' in nut_driver_config" libhid-ups nut-usb-hotplug notice nd_driver_config_error=true return 0 } else # Initscript should have its own logging, and we do not exit with # error as that would abort processing other devices - logger -s -t nut-usb-hotplug "NUT server disabled when processing '$ACTION' for '$DEVNAME'." + log_msg "NUT server disabled when processing '$ACTION' for '$DEVNAME'." "libhid-ups" nut-usb-hotplug notice return 0 fi else @@ -192,12 +192,12 @@ nut_driver_config() { fi elif [ -n "$cfg_vendorid" ] && [ -n "$cfg_productid" ] && [ -n "$pvendid" ] && [ -n "$pprodid" ]; then if ! check_valid_hex_number "$pvendid"; then - logger -s -t nut-usb-hotplug "Hotplug vendor id for '$ups' is not valid" + log_error "Hotplug vendor id for '$ups' is not valid" "libhid-ups" nut-usb-hotplug nd_driver_config_error=true return 0 fi if ! check_valid_hex_number "$pprodid"; then - logger -s -t nut-usb-hotplug "Hotplug product id for '$ups' is not valid" + log_error "Hotplug product id for '$ups' is not valid" "libhid-ups" nut-usb-hotplug nd_driver_config_error=true return 0 fi @@ -230,12 +230,12 @@ perform_libhid_action() { # Only find statepath and runas once per event # defines STATEPATH find_statepath "upsd" "nut_server" || { - logger -s -t nut-usb-hotplug "Failed to set STATEPATH" + log_error "Failed to set STATEPATH" "libhid-ups" nut-usb-hotplug return 1 } # sets RUNAS find_runas "upsd" "nut_server" || { - logger -s -t nut-usb-hotplug "Failed to set RUNAS" + log_error "Failed to set RUNAS" "libhid-ups" nut-usb-hotplug return 1 } @@ -284,7 +284,7 @@ perform_libhid_action() { # and not already stopped, will be stopped. This is preferable to doing # nothing on removals. if ! allow_hotplug_restart; then - logger -s -t nut-usb-hotplug "Hotplug restart disabled when processing '$ACTION' for '$DEVNAME'" + log_msg "Hotplug restart disabled when processing '$ACTION' for '$DEVNAME'" "libhid-ups" nut-usb-hotplug notice return 0 fi # We check enabled again here, in case of a race condition since @@ -296,7 +296,7 @@ perform_libhid_action() { fi return 0 else - logger -s -t nut-usb-hotplug "NUT server disabled when processing '$ACTION' for '$DEVNAME'." + log_msg "NUT server disabled when processing '$ACTION' for '$DEVNAME'." "libhid-ups" nut-usb-hotplug notice return 0 fi # We do not return 0 here as it is unnecessary (all if branches have a @@ -324,13 +324,13 @@ case "$PRODUCT" in # NUT_DISABLE_HOTPLUG_PATH is an external sentinel used to indicate NUT # hotplug is disabled. if ! allow_hotplug_restart; then - logger -s -t nut-usb-hotplug "Hotplug restart disabled when processing '$ACTION' for '$DEVNAME'" + log_msg "Hotplug restart disabled when processing '$ACTION' for '$DEVNAME'" "libhid-ups" nut-usb-hotplug notice exit 0 fi # We check enabled again here, in case of a race condition since # our last check. if ! /etc/init.d/nut-server enabled; then - logger -s -t nut-usb-hotplug "NUT server disabled when processing '$ACTION' for '$DEVNAME'." + log_msg "NUT server disabled when processing '$ACTION' for '$DEVNAME'." "libhid-ups" nut-usb-hotplug notice exit 0 fi if ! perform_libhid_action; then diff --git a/net/nut/files/nut-cgi.init b/net/nut/files/nut-cgi.init index 9cd65089d..9aea83c94 100644 --- a/net/nut/files/nut-cgi.init +++ b/net/nut/files/nut-cgi.init @@ -280,7 +280,7 @@ service_reload() { return 1 fi # Empty hosts is not necessarily an error, but we log for information - logger -s -t nut-cgi "No configured hosts" + log_msg "No configured hosts" nut-cgi nut-cgi info fi # NUT CGI host file configuration is independent of upsset configuration diff --git a/net/nut/files/nut-serial.hotplug b/net/nut/files/nut-serial.hotplug index 9da375df8..d7e300525 100644 --- a/net/nut/files/nut-serial.hotplug +++ b/net/nut/files/nut-serial.hotplug @@ -139,7 +139,7 @@ nut_on_hotplug_add() { # attempt to reload the driver and/or server if [ "$did_set_perms" = "true" ]; then # Informational and not an error - logger -t nut-serial-hotplug "Successfully set permissions for serial device(s)" + log_msg "Successfully set permissions for serial device(s)" nut-serial nut-serial-hotplug info # We shouldn't get here if hotplug is disabled (race condition if we do), so log it as an error if ! allow_hotplug_restart; then log_error "Did not restart NUT after setting permissions as hotplug restart is disabled" nut-serial nut-serial-hotplug @@ -163,7 +163,7 @@ nut_on_hotplug_add() { # for information if ! allow_hotplug_restart; then # Informational and not an error - logger -t nut-serial-hotplug "Did not set permissions on serial port hotplug as NUT hotplug is disabled" + log_msg "Did not set permissions on serial port hotplug as NUT hotplug is disabled" nut-serial nut-serial-hotplug notice exit 0 fi diff --git a/net/nut/files/nut-server.init b/net/nut/files/nut-server.init index 8a80d2ede..7293627f4 100644 --- a/net/nut/files/nut-server.init +++ b/net/nut/files/nut-server.init @@ -397,7 +397,7 @@ reload_ups_driver() { stop_service_if_no_instances() { if service_active_no_instances "nut-server"; then - logger -t "nut-server" "nut-server active with no instances" + log_msg "nut-server active with no instances" nut-server "nut-server" notice # 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. diff --git a/net/nut/files/nut-service.sh.functions b/net/nut/files/nut-service.sh.functions index 54e138cdc..b8a4ded76 100644 --- a/net/nut/files/nut-service.sh.functions +++ b/net/nut/files/nut-service.sh.functions @@ -67,7 +67,7 @@ list_running_instances() { if [ -n "$running_instances" ]; then json_init json_load "$running_instances" || { - logger -s -t nut-service "json_load failed in list_running_instances" + log_error "json_load failed in list_running_instances" nut-service.sh nut-service return 1 } json_get_keys instance_names @@ -139,7 +139,7 @@ signal_instance() { # We only want to issue secondary command if the primary command fails if [ "$ret" = "1" ] && [ -n "$secondary_command" ] && procd_running "$service_name" "$instance_name"; then # Informational log message, not error - logger -s -t "$service_name" "Performing '$secondary_command' $* for '$instance_name'" + log_msg "Performing '$secondary_command' $* for '$instance_name'" nut-service.sh "$service_name" info set -f "$secondary_command" "$@" 2>&1 | logger -t "$service_name" set +f