mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 11:40:08 +01:00
platform: add _LOG() logging macros to linux platform
(cherry picked from commit 7db9306aa3)
This commit is contained in:
parent
2f4db91fcc
commit
3ded80d143
1 changed files with 42 additions and 0 deletions
|
|
@ -67,10 +67,52 @@
|
|||
/* This is only included for the translation of VLAN flags */
|
||||
#include "nm-setting-vlan.h"
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
#define _LOG_DOMAIN LOGD_PLATFORM
|
||||
#define _LOG_PREFIX_NAME "platform-linux"
|
||||
|
||||
#define _LOG(level, domain, self, ...) \
|
||||
G_STMT_START { \
|
||||
const NMLogLevel __level = (level); \
|
||||
const NMLogDomain __domain = (domain); \
|
||||
\
|
||||
if (nm_logging_enabled (__level, __domain)) { \
|
||||
char __prefix[32]; \
|
||||
const char *__p_prefix = _LOG_PREFIX_NAME; \
|
||||
const void *const __self = (self); \
|
||||
\
|
||||
if (__self && __self != nm_platform_try_get ()) { \
|
||||
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _LOG_PREFIX_NAME, __self); \
|
||||
__p_prefix = __prefix; \
|
||||
} \
|
||||
_nm_log (__level, __domain, 0, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
__p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
#define _LOG_LEVEL_ENABLED(level, domain) \
|
||||
( nm_logging_enabled ((level), (domain)) )
|
||||
|
||||
#ifdef NM_MORE_LOGGING
|
||||
#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN)
|
||||
#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DOMAIN, platform, __VA_ARGS__)
|
||||
#else
|
||||
#define _LOGT_ENABLED() FALSE
|
||||
#define _LOGT(...) G_STMT_START { (void) 0; } G_STMT_END
|
||||
#endif
|
||||
|
||||
#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, platform, __VA_ARGS__)
|
||||
#define _LOGI(...) _LOG (LOGL_INFO , _LOG_DOMAIN, platform, __VA_ARGS__)
|
||||
#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, platform, __VA_ARGS__)
|
||||
#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, platform, __VA_ARGS__)
|
||||
|
||||
#define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__)
|
||||
#define warning(...) nm_log_warn (LOGD_PLATFORM, __VA_ARGS__)
|
||||
#define error(...) nm_log_err (LOGD_PLATFORM, __VA_ARGS__)
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
#define return_type(t, name) \
|
||||
G_STMT_START { \
|
||||
if (out_name) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue