diff options
author | Thomas Haller <thaller@redhat.com> | 2021-04-09 13:15:43 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-04-12 16:46:01 +0200 |
commit | 1353a0e8da2db98eac571560654ef360e9e830d8 (patch) | |
tree | d4eb64cba4804ddae4107979cb46d636db4d442e | |
parent | 7074fa0ef5d81aad8f52f572e3273d04092ab7c9 (diff) | |
download | NetworkManager-1353a0e8da2db98eac571560654ef360e9e830d8.tar.gz |
logging: add _nm_log_full() macro
_nm_log_impl() is the underlying implementation. As we have
multiple implementations, it's a bit confusing how it all works
together.
We thus should not call this directly, so that there are few (literal)
uses of this symbol.
Still, we may need to call this version of the logging statement,
because it's the only one that allows to provide the file location.
Add a wrapper macro for this, that callers can use.
-rw-r--r-- | src/libnm-glib-aux/nm-logging-fwd.h | 2 | ||||
-rw-r--r-- | src/libnm-log-core/nm-logging.h | 26 | ||||
-rw-r--r-- | src/libnm-systemd-shared/src/basic/log.h | 2 |
3 files changed, 14 insertions, 16 deletions
diff --git a/src/libnm-glib-aux/nm-logging-fwd.h b/src/libnm-glib-aux/nm-logging-fwd.h index df0bb161e1..0ede91b2bc 100644 --- a/src/libnm-glib-aux/nm-logging-fwd.h +++ b/src/libnm-glib-aux/nm-logging-fwd.h @@ -93,6 +93,8 @@ void _nm_log_impl(const char *file, const char *fmt, ...) _nm_printf(10, 11); +#define _nm_log_full(...) _nm_log_impl(__VA_ARGS__) + static inline NMLogLevel nm_log_level_from_syslog(int syslog_level) { diff --git a/src/libnm-log-core/nm-logging.h b/src/libnm-log-core/nm-logging.h index 574c225c2e..8eecb7e41b 100644 --- a/src/libnm-log-core/nm-logging.h +++ b/src/libnm-log-core/nm-logging.h @@ -26,24 +26,20 @@ //#define _NM_LOG_FUNC G_STRFUNC #define _NM_LOG_FUNC NULL -/* A wrapper for the _nm_log_impl() function that adds call site information. +/* A wrapper for _nm_log_full() function that adds call site information. * Contrary to nm_log(), it unconditionally calls the function without * checking whether logging for the given level and domain is enabled. */ #define _nm_log_mt(mt_require_locking, level, domain, error, ifname, con_uuid, ...) \ - G_STMT_START \ - { \ - _nm_log_impl(__FILE__, \ - __LINE__, \ - _NM_LOG_FUNC, \ - (mt_require_locking), \ - (level), \ - (domain), \ - (error), \ - (ifname), \ - (con_uuid), \ - ""__VA_ARGS__); \ - } \ - G_STMT_END + _nm_log_full(__FILE__, \ + __LINE__, \ + _NM_LOG_FUNC, \ + (mt_require_locking), \ + (level), \ + (domain), \ + (error), \ + (ifname), \ + (con_uuid), \ + ""__VA_ARGS__) #define _nm_log(level, domain, error, ifname, con_uuid, ...) \ _nm_log_mt(!(NM_THREAD_SAFE_ON_MAIN_THREAD), \ diff --git a/src/libnm-systemd-shared/src/basic/log.h b/src/libnm-systemd-shared/src/basic/log.h index bcb3d494a1..0664977562 100644 --- a/src/libnm-systemd-shared/src/basic/log.h +++ b/src/libnm-systemd-shared/src/basic/log.h @@ -113,7 +113,7 @@ int log_internal( if (_nm_log_enabled_impl(!(NM_THREAD_SAFE_ON_MAIN_THREAD), _nm_l, LOGD_SYSTEMD)) { \ const char *_nm_location = strrchr(("" file), '/'); \ \ - _nm_log_impl(_nm_location ? _nm_location + 1 : ("" file), \ + _nm_log_full(_nm_location ? _nm_location + 1 : ("" file), \ (line), \ (func), \ !(NM_THREAD_SAFE_ON_MAIN_THREAD), \ |