mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 20:10:17 +01:00
libnm: add define for disabling NMClient debug logging
For printf debugging (when you recompile the source) it can be useful to have one switch to disable logging of NMClient. For example, this is useful with $ LIBNM_CLIENT_DEBUG=trace nmcli agent secret
This commit is contained in:
parent
6e7e18c86f
commit
64c53a2afa
1 changed files with 17 additions and 2 deletions
|
|
@ -31,6 +31,8 @@ gboolean nm_utils_g_param_spec_is_default (const GParamSpec *pspec);
|
|||
/*****************************************************************************/
|
||||
|
||||
typedef enum {
|
||||
_NML_DBUS_LOG_LEVEL_NONE = 0x00,
|
||||
|
||||
_NML_DBUS_LOG_LEVEL_INITIALIZED = 0x01,
|
||||
|
||||
_NML_DBUS_LOG_LEVEL_TRACE = 0x02,
|
||||
|
|
@ -83,6 +85,7 @@ nml_dbus_log_enabled (NMLDBusLogLevel level)
|
|||
int l;
|
||||
|
||||
nm_assert (NM_IN_SET (level, NML_DBUS_LOG_LEVEL_ANY,
|
||||
_NML_DBUS_LOG_LEVEL_NONE,
|
||||
NML_DBUS_LOG_LEVEL_TRACE,
|
||||
NML_DBUS_LOG_LEVEL_DEBUG,
|
||||
NML_DBUS_LOG_LEVEL_WARN,
|
||||
|
|
@ -104,7 +107,8 @@ void _nml_dbus_log (NMLDBusLogLevel level,
|
|||
|
||||
#define NML_DBUS_LOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
G_STATIC_ASSERT ( (level) == NML_DBUS_LOG_LEVEL_TRACE \
|
||||
G_STATIC_ASSERT ( (level) == _NML_DBUS_LOG_LEVEL_NONE \
|
||||
|| (level) == NML_DBUS_LOG_LEVEL_TRACE \
|
||||
|| (level) == NML_DBUS_LOG_LEVEL_DEBUG \
|
||||
|| (level) == NML_DBUS_LOG_LEVEL_WARN \
|
||||
|| (level) == NML_DBUS_LOG_LEVEL_ERROR); \
|
||||
|
|
@ -119,8 +123,19 @@ void _nml_dbus_log (NMLDBusLogLevel level,
|
|||
#define NML_DBUS_LOG_W(...) NML_DBUS_LOG (NML_DBUS_LOG_LEVEL_WARN, __VA_ARGS__)
|
||||
#define NML_DBUS_LOG_E(...) NML_DBUS_LOG (NML_DBUS_LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||
|
||||
/* _NML_NMCLIENT_LOG_LEVEL_COERCE is only for printf debugging. You can disable client logging by
|
||||
* mapping the requested log level to a different one (or disable it altogether).
|
||||
* That's useful for example if you are interested in *other* trace logging messages from
|
||||
* libnm and don't want to get flooded by NMClient's trace messages. */
|
||||
#define _NML_NMCLIENT_LOG_LEVEL_COERCE(level) \
|
||||
/* for example, change condition below to suppress <trace> messages from NMClient. */ \
|
||||
(( TRUE \
|
||||
|| ((level) != NML_DBUS_LOG_LEVEL_TRACE)) \
|
||||
? (level) \
|
||||
: _NML_DBUS_LOG_LEVEL_NONE)
|
||||
|
||||
#define NML_NMCLIENT_LOG(level, self, ...) \
|
||||
NML_DBUS_LOG ((level), \
|
||||
NML_DBUS_LOG (_NML_NMCLIENT_LOG_LEVEL_COERCE (level), \
|
||||
"nmclient["NM_HASH_OBFUSCATE_PTR_FMT"]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
NM_HASH_OBFUSCATE_PTR (self) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue