mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 08:10:22 +01:00
vpn-connection: add logging macros _LOG*()
This commit is contained in:
parent
d48ed98eb3
commit
72c85c29a7
1 changed files with 55 additions and 0 deletions
|
|
@ -151,6 +151,61 @@ static void _set_vpn_state (NMVpnConnection *self,
|
|||
|
||||
/*********************************************************************/
|
||||
|
||||
#define _NMLOG_DOMAIN LOGD_VPN
|
||||
#define _NMLOG_PREFIX_NAME "vpn-connection"
|
||||
|
||||
#define __NMLOG_prefix_buf_len 128
|
||||
|
||||
static const char *
|
||||
__LOG_create_prefix (char *buf, NMVpnConnection *self)
|
||||
{
|
||||
NMVpnConnectionPrivate *priv;
|
||||
NMConnection *con;
|
||||
const char *id;
|
||||
|
||||
if (!self)
|
||||
return _NMLOG_PREFIX_NAME;
|
||||
|
||||
priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
|
||||
|
||||
con = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (self));
|
||||
id = con ? nm_connection_get_id (con) : NULL;
|
||||
|
||||
g_snprintf (buf, __NMLOG_prefix_buf_len,
|
||||
"%s["
|
||||
"%p" /*self*/
|
||||
"%s%s" /*con-uuid*/
|
||||
"%s%s%s%s" /*con-id*/
|
||||
",%d" /*ifindex*/
|
||||
"%s%s%s%s" /*iface*/
|
||||
"]",
|
||||
_NMLOG_PREFIX_NAME,
|
||||
self,
|
||||
con ? "," : "--", con ? str_if_set (nm_connection_get_uuid (con), "??") : "",
|
||||
con ? "," : "", NM_PRINT_FMT_QUOTED (id, "\"", id, "\"", con ? "??" : ""),
|
||||
priv->ip_ifindex,
|
||||
priv->ip_iface ? ":" : "", NM_PRINT_FMT_QUOTED (priv->ip_iface, "(", priv->ip_iface, ")", "")
|
||||
);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
const NMLogLevel __level = (level); \
|
||||
\
|
||||
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
|
||||
char __prefix[__NMLOG_prefix_buf_len]; \
|
||||
\
|
||||
_nm_log (__level, _NMLOG_DOMAIN, 0, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
__LOG_create_prefix (__prefix, self) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
static NMVpnConnectionState
|
||||
_state_to_nm_vpn_state (VpnState state)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue