libnm: print timestamp in LIBNM_CLIENT_DEBUG debug logging

It's useful, because it's easy to get overwhelemed by the logging output.
The timestamp makes it easier to keep track. Also, it allows to see how long
things take.
This commit is contained in:
Thomas Haller
2019-10-29 16:50:08 +01:00
parent 1463450393
commit 9c01d6ca67

View File

@@ -8,6 +8,8 @@
#include "nm-libnm-utils.h" #include "nm-libnm-utils.h"
#include "nm-glib-aux/nm-time-utils.h"
/*****************************************************************************/ /*****************************************************************************/
volatile int _nml_dbus_log_level = 0; volatile int _nml_dbus_log_level = 0;
@@ -43,6 +45,7 @@ _nml_dbus_log (NMLDBusLogLevel level,
gs_free char *msg = NULL; gs_free char *msg = NULL;
va_list args; va_list args;
const char *prefix = ""; const char *prefix = "";
gint64 ts;
/* we only call _nml_dbus_log() after nml_dbus_log_enabled(), which already does /* we only call _nml_dbus_log() after nml_dbus_log_enabled(), which already does
* an atomic access to the variable. Since the value is only initialized once and * an atomic access to the variable. Since the value is only initialized once and
@@ -84,7 +87,13 @@ _nml_dbus_log (NMLDBusLogLevel level,
break; break;
} }
g_printerr ("libnm-dbus: %s%s\n", prefix, msg); ts = nm_utils_clock_gettime_ns (CLOCK_BOOTTIME);
g_printerr ("libnm-dbus: %s[%"G_GINT64_FORMAT".%05"G_GINT64_FORMAT"] %s\n",
prefix,
ts / NM_UTILS_NS_PER_SECOND,
(ts / (NM_UTILS_NS_PER_SECOND / 10000)) % 10000,
msg);
} }
/*****************************************************************************/ /*****************************************************************************/