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.
This commit is contained in:
Thomas Haller 2023-11-17 14:43:10 +01:00
parent 5c08fa2776
commit 15d17febeb
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -177,17 +177,13 @@ _nml_dbus_log(NMLDBusLogLevel level, gboolean use_stdout, const char *fmt, ...)
break;
case NML_DBUS_LOG_LEVEL_WARN:
prefix = "<warn > ";
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 = "<error> ";
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;