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.
This commit is contained in:
Thomas Haller
2021-04-09 13:15:43 +02:00
parent 7074fa0ef5
commit 1353a0e8da
3 changed files with 14 additions and 16 deletions

View File

@@ -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), \