From 15d17febeb6d5fbca47335fb78ac085d43acf143 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 17 Nov 2023 14:43:10 +0100 Subject: [PATCH] libnm: with LIBNM_CLIENT_DEBUG logging always print to default destination With enabled assertions via LIBNM_CLIENT_DEBUG=WARN or LIBNM_CLIENT_DEBUG=ERROR, still print the warning/error message to the default destination, along the trace/debug messages. For example, when you set LIBNM_CLIENT_DEBUG_FILE, then we want that those messages end up in the file too, not only in g_log() output. Also, g_warning() prints to stderr. If you set LIBNM_CLIENT_DEBUG="WARN,trace,stdout", then we printed the warning to stderr and the trace messages to stdout. All debug messages should and up at the same place, and the g_warning() and g_critical() messages are additional. Also because glib's g_log() supports its own redirection and suppression mechanism. --- src/libnm-client-impl/nm-libnm-utils.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c index fea3c3af38..9ebca2167f 100644 --- a/src/libnm-client-impl/nm-libnm-utils.c +++ b/src/libnm-client-impl/nm-libnm-utils.c @@ -177,17 +177,13 @@ _nml_dbus_log(NMLDBusLogLevel level, gboolean use_stdout, const char *fmt, ...) break; case NML_DBUS_LOG_LEVEL_WARN: prefix = " "; - if (NM_FLAGS_HAS(configured_log_level, NML_DBUS_LOG_ASSERT)) { + if (NM_FLAGS_HAS(configured_log_level, NML_DBUS_LOG_ASSERT)) g_warning("libnm-dbus: %s%s", prefix, msg); - return; - } break; case NML_DBUS_LOG_LEVEL_ERROR: prefix = " "; - if (NM_FLAGS_HAS(configured_log_level, NML_DBUS_LOG_ASSERT)) { + if (NM_FLAGS_HAS(configured_log_level, NML_DBUS_LOG_ASSERT)) g_critical("libnm-dbus: %s%s", prefix, msg); - return; - } break; default: break;