Commit ed552c73 authored by Lubomir Rintel's avatar Lubomir Rintel 🥕

logging: log device and connection along with the message

parent 03a3fd90
......@@ -82,7 +82,7 @@ G_DEFINE_TYPE (NMArpingManager, nm_arping_manager, G_TYPE_OBJECT)
G_STMT_START { \
char _sbuf[64]; \
\
nm_log ((level), _NMLOG_DOMAIN, \
nm_log ((level), _NMLOG_DOMAIN, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
self ? nm_sprintf_buf (_sbuf, "[%p,%d]", \
......
......@@ -34,7 +34,7 @@ _nm_device_log_self_to_device (t *self) \
#undef _NMLOG_ENABLED
#define _NMLOG_ENABLED(level, domain) ( nm_logging_enabled ((level), (domain)) )
#define _NMLOG(level, domain, ...) \
nm_log_obj ((level), (domain), (self), "device", \
nm_log_obj ((level), (domain), NULL, NULL, (self), "device", \
"(%s): " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(self) ? (nm_device_get_iface (_nm_device_log_self_to_device (self)) ?: "(null)") : "(none)" \
_NM_UTILS_MACRO_REST(__VA_ARGS__))
......
......@@ -127,7 +127,7 @@ typedef struct {
char _sbuf[64]; \
int _ifindex = (self) ? NM_LLDP_LISTENER_GET_PRIVATE (self)->ifindex : 0; \
\
_nm_log (_level, _NMLOG_DOMAIN, 0, \
_nm_log (_level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
((_ifindex > 0) \
......
......@@ -119,7 +119,7 @@ G_DEFINE_TYPE (NMModemBroadband, nm_modem_broadband, NM_TYPE_MODEM)
char __prefix_name[128]; \
const char *__uid; \
\
_nm_log (_level, (_NMLOG_DOMAIN), 0, \
_nm_log (_level, (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(__self \
......
......@@ -83,7 +83,7 @@ G_DEFINE_TYPE (NMModemOfono, nm_modem_ofono, NM_TYPE_MODEM)
char __prefix_name[128]; \
const char *__uid; \
\
_nm_log (_level, (_NMLOG_DOMAIN), 0, \
_nm_log (_level, (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(__self \
......
......@@ -42,7 +42,7 @@
? LOGD_DHCP \
: (nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4); \
\
nm_log (_level, _domain, \
nm_log (_level, _domain, NULL, NULL, \
"%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
......@@ -65,7 +65,7 @@
if (nm_logging_enabled (_level, _domain)) { \
const char *__ifname = (ifname); \
\
nm_log (_level, _domain, \
nm_log (_level, _domain, NULL, NULL, \
"%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
......
......@@ -92,7 +92,7 @@ NM_DEFINE_SINGLETON_GETTER (NMDhcpListener, nm_dhcp_listener_get, NM_TYPE_DHCP_L
const NMDhcpListener *_self = (self); \
char _prefix[64]; \
\
nm_log ((level), (_NMLOG_DOMAIN), \
nm_log ((level), (_NMLOG_DOMAIN), NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(_self != singleton_instance \
? nm_sprintf_buf (_prefix, "%s[%p]", _NMLOG_PREFIX_NAME, _self) \
......
......@@ -104,7 +104,7 @@ NM_DEFINE_SINGLETON_GETTER (NMDnsManager, nm_dns_manager_get, NM_TYPE_DNS_MANAGE
char __prefix[20]; \
const NMDnsManager *const __self = (self); \
\
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
((!__self || __self == singleton_instance) \
......
......@@ -63,7 +63,7 @@ G_DEFINE_TYPE_EXTENDED (NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT, G_TYPE_FLAG_A
char __prefix[20]; \
const NMDnsPlugin *const __self = (self); \
\
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(!__self \
......
......@@ -59,7 +59,7 @@ gboolean nm_ndisc_add_dns_domain (NMNDisc *ndisc, const NMNDiscDNSDoma
NMNDisc *const __self = (self); \
char __prefix[64]; \
\
_nm_log (__level, __domain, 0, \
_nm_log (__level, __domain, 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
(__self \
? ({ \
......
......@@ -122,7 +122,7 @@ static void _set_activation_type (NMActiveConnection *self,
G_STMT_START { \
char _sbuf[64]; \
\
nm_log ((level), _NMLOG_DOMAIN, \
nm_log ((level), _NMLOG_DOMAIN, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
self ? nm_sprintf_buf (_sbuf, "[%p]", self) : "" \
......
......@@ -77,7 +77,7 @@ G_DEFINE_TYPE (NMAuditManager, nm_audit_manager, G_TYPE_OBJECT)
#define _NMLOG_PREFIX_NAME "audit"
#define _NMLOG(level, domain, ...) \
G_STMT_START { \
nm_log ((level), (domain), \
nm_log ((level), (domain), NULL, NULL, \
"%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME": " \
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
......
......@@ -79,7 +79,7 @@ NM_DEFINE_SINGLETON_REGISTER (NMAuthManager);
\
if ((self) != singleton_instance) \
g_snprintf (__prefix, sizeof (__prefix), ""_NMLOG_PREFIX_NAME"[%p]", (self)); \
_nm_log ((level), (_NMLOG_DOMAIN), 0, \
_nm_log ((level), (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
......
......@@ -94,7 +94,7 @@ G_DEFINE_TYPE (NMCheckpoint, nm_checkpoint, NM_TYPE_EXPORTED_OBJECT)
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \
else \
g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \
_nm_log ((level), (_NMLOG_DOMAIN), 0, \
_nm_log ((level), (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
......
......@@ -601,7 +601,7 @@ nm_config_data_log (const NMConfigData *self,
#define _LOG(stream, prefix, ...) \
G_STMT_START { \
if (!stream) \
_nm_log (LOGL_DEBUG, LOGD_CORE, 0, "%s"_NM_UTILS_MACRO_FIRST(__VA_ARGS__)"%s", prefix _NM_UTILS_MACRO_REST (__VA_ARGS__), ""); \
_nm_log (LOGL_DEBUG, LOGD_CORE, 0, NULL, NULL, "%s"_NM_UTILS_MACRO_FIRST(__VA_ARGS__)"%s", prefix _NM_UTILS_MACRO_REST (__VA_ARGS__), ""); \
else \
fprintf (stream, "%s"_NM_UTILS_MACRO_FIRST(__VA_ARGS__)"%s", prefix _NM_UTILS_MACRO_REST (__VA_ARGS__), "\n"); \
} G_STMT_END
......
......@@ -438,11 +438,11 @@ nm_utils_modprobe (GError **error, gboolean suppress_error_logging, const char *
nm_log_dbg (LOGD_CORE, "modprobe: '%s'", ARGV_TO_STR (argv));
if (!g_spawn_sync (NULL, (char **) argv->pdata, NULL, 0, NULL, NULL, &std_out, &std_err, &exit_status, &local)) {
nm_log (llevel, LOGD_CORE, "modprobe: '%s' failed: %s", ARGV_TO_STR (argv), local->message);
nm_log (llevel, LOGD_CORE, NULL, NULL, "modprobe: '%s' failed: %s", ARGV_TO_STR (argv), local->message);
g_propagate_error (error, local);
return -1;
} else if (exit_status != 0) {
nm_log (llevel, LOGD_CORE, "modprobe: '%s' exited with error %d%s%s%s%s%s%s", ARGV_TO_STR (argv), exit_status,
nm_log (llevel, LOGD_CORE, NULL, NULL, "modprobe: '%s' exited with error %d%s%s%s%s%s%s", ARGV_TO_STR (argv), exit_status,
std_out&&*std_out ? " (" : "", std_out&&*std_out ? _trunk_first_line (std_out) : "", std_out&&*std_out ? ")" : "",
std_err&&*std_err ? " (" : "", std_err&&*std_err ? _trunk_first_line (std_err) : "", std_err&&*std_err ? ")" : "");
}
......@@ -2431,9 +2431,9 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
connection_diff_are_same = nm_connection_diff (connection, diff_base, NM_SETTING_COMPARE_FLAG_EXACT | NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT, &connection_diff);
if (connection_diff_are_same) {
if (diff_base)
nm_log (level, domain, "%sconnection '%s' (%p/%s and %p/%s): no difference", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base));
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s and %p/%s): no difference", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base));
else
nm_log (level, domain, "%sconnection '%s' (%p/%s): no properties set", prefix, name, connection, G_OBJECT_TYPE_NAME (connection));
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s): no properties set", prefix, name, connection, G_OBJECT_TYPE_NAME (connection));
g_assert (!connection_diff);
return;
}
......@@ -2469,16 +2469,16 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
const char *path = nm_connection_get_path (connection);
if (diff_base) {
nm_log (level, domain, "%sconnection '%s' (%p/%s < %p/%s)%s%s%s:", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base),
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s < %p/%s)%s%s%s:", prefix, name, connection, G_OBJECT_TYPE_NAME (connection), diff_base, G_OBJECT_TYPE_NAME (diff_base),
NM_PRINT_FMT_QUOTED (path, " [", path, "]", ""));
} else {
nm_log (level, domain, "%sconnection '%s' (%p/%s):%s%s%s", prefix, name, connection, G_OBJECT_TYPE_NAME (connection),
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s):%s%s%s", prefix, name, connection, G_OBJECT_TYPE_NAME (connection),
NM_PRINT_FMT_QUOTED (path, " [", path, "]", ""));
}
print_header = FALSE;
if (!nm_connection_verify (connection, &err_verify)) {
nm_log (level, domain, "%sconnection %p does not verify: %s", prefix, connection, err_verify->message);
nm_log (level, domain, NULL, NULL, "%sconnection %p does not verify: %s", prefix, connection, err_verify->message);
g_clear_error (&err_verify);
}
}
......@@ -2491,21 +2491,21 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
g_string_printf (str1, "*missing* < %p", setting_data->diff_base_setting);
else
g_string_printf (str1, "%p < *missing*", setting_data->setting);
nm_log (level, domain, "%s%"_NM_LOG_ALIGN"s [ %s ]", prefix, setting_data->name, str1->str);
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s [ %s ]", prefix, setting_data->name, str1->str);
} else
nm_log (level, domain, "%s%"_NM_LOG_ALIGN"s [ %p ]", prefix, setting_data->name, setting_data->setting);
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s [ %p ]", prefix, setting_data->name, setting_data->setting);
print_setting_header = FALSE;
}
g_string_printf (str1, "%s.%s", setting_data->name, item->item_name);
switch (item->diff_result & (NM_SETTING_DIFF_RESULT_IN_A | NM_SETTING_DIFF_RESULT_IN_B)) {
case NM_SETTING_DIFF_RESULT_IN_B:
nm_log (level, domain, "%s%"_NM_LOG_ALIGN"s < %s", prefix, str1->str, str_diff ? str_diff : "NULL");
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s < %s", prefix, str1->str, str_diff ? str_diff : "NULL");
break;
case NM_SETTING_DIFF_RESULT_IN_A:
nm_log (level, domain, "%s%"_NM_LOG_ALIGN"s = %s", prefix, str1->str, str_conn ? str_conn : "NULL");
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s = %s", prefix, str1->str, str_conn ? str_conn : "NULL");
break;
default:
nm_log (level, domain, "%s%"_NM_LOG_ALIGN"s = %s < %s", prefix, str1->str, str_conn ? str_conn : "NULL", str_diff ? str_diff : "NULL");
nm_log (level, domain, NULL, NULL, "%s%"_NM_LOG_ALIGN"s = %s < %s", prefix, str1->str, str_conn ? str_conn : "NULL", str_diff ? str_diff : "NULL");
break;
#undef _NM_LOG_ALIGN
}
......
......@@ -97,7 +97,7 @@ NM_DEFINE_SINGLETON_GETTER (NMDefaultRouteManager, nm_default_route_manager_get,
if (nm_logging_enabled (__level, __domain)) { \
char __prefix_buf[100]; \
\
_nm_log (__level, __domain, 0, \
_nm_log (__level, __domain, 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
self != singleton_instance \
? nm_sprintf_buf (__prefix_buf, "%s%c[%p]", \
......@@ -123,7 +123,7 @@ NM_DEFINE_SINGLETON_GETTER (NMDefaultRouteManager, nm_default_route_manager_get,
guint __entry_idx = (entry_idx); \
const Entry *const __entry = (entry); \
\
_nm_log (__level, __domain, 0, \
_nm_log (__level, __domain, 0, NULL, NULL, \
"%s: entry[%u/%s:%p:%s:%chas:%csync]: "_NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
self != singleton_instance \
? nm_sprintf_buf (__prefix_buf, "%s%c[%p]", \
......
......@@ -118,7 +118,7 @@ _ops_type_to_string (CBInfoOpsType ops_type)
char __prefix_name[30]; \
char __prefix_info[64]; \
\
_nm_log ((level), (_NMLOG_DOMAIN), 0, \
_nm_log ((level), (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s: %s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(self) != singleton_instance \
? ({ \
......
......@@ -91,7 +91,7 @@ static struct {
#define _NMLOG_PREFIX_NAME "nm-iface-helper"
#define _NMLOG(level, domain, ...) \
nm_log ((level), (domain), \
nm_log ((level), (domain), NULL, NULL, \
"iface-helper: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__) \
_NM_UTILS_MACRO_REST (__VA_ARGS__))
......
......@@ -594,6 +594,8 @@ _nm_log_impl (const char *file,
NMLogLevel level,
NMLogDomain domain,
int error,
const char *ifname,
const char *conn_uuid,
const char *fmt,
...)
{
......@@ -642,7 +644,7 @@ _nm_log_impl (const char *file,
#define _NUM_MAX_FIELDS_SYSLOG_FACILITY 10
struct iovec iov_data[12 + _NUM_MAX_FIELDS_SYSLOG_FACILITY];
struct iovec *iov = iov_data;
gpointer iov_free_data[3];
gpointer iov_free_data[5];
gpointer *iov_free = iov_free_data;
nm_auto_free_gstring GString *s_domain_all = NULL;
......@@ -704,6 +706,10 @@ _nm_log_impl (const char *file,
_iovec_set_format_a (iov++, 60, "TIMESTAMP_BOOTTIME=%lld.%06lld", (long long) (boottime / NM_UTILS_NS_PER_SECOND), (long long) ((boottime % NM_UTILS_NS_PER_SECOND) / 1000));
if (error != 0)
_iovec_set_format_a (iov++, 30, "ERRNO=%d", error);
if (ifname)
_iovec_set_format (iov++, iov_free++, "NM_DEVICE=%s", ifname);
if (conn_uuid)
_iovec_set_format (iov++, iov_free++, "NM_CONNECTION=%s", conn_uuid);
nm_assert (iov <= &iov_data[G_N_ELEMENTS (iov_data)]);
nm_assert (iov_free <= &iov_free_data[G_N_ELEMENTS (iov_free_data)]);
......
......@@ -22,6 +22,8 @@
#ifndef __NETWORKMANAGER_LOGGING_H__
#define __NETWORKMANAGER_LOGGING_H__
#include "nm-core-types.h"
#ifdef __NM_TEST_UTILS_H__
#error nm-test-utils.h must be included as last header
#endif
......@@ -97,11 +99,11 @@ typedef enum { /*< skip >*/
_LOGL_N, /* the number of logging levels including "OFF" */
} NMLogLevel;
#define nm_log_err(domain, ...) nm_log (LOGL_ERR, (domain), __VA_ARGS__)
#define nm_log_warn(domain, ...) nm_log (LOGL_WARN, (domain), __VA_ARGS__)
#define nm_log_info(domain, ...) nm_log (LOGL_INFO, (domain), __VA_ARGS__)
#define nm_log_dbg(domain, ...) nm_log (LOGL_DEBUG, (domain), __VA_ARGS__)
#define nm_log_trace(domain, ...) nm_log (LOGL_TRACE, (domain), __VA_ARGS__)
#define nm_log_err(domain, ...) nm_log (LOGL_ERR, (domain), NULL, NULL, __VA_ARGS__)
#define nm_log_warn(domain, ...) nm_log (LOGL_WARN, (domain), NULL, NULL, __VA_ARGS__)
#define nm_log_info(domain, ...) nm_log (LOGL_INFO, (domain), NULL, NULL, __VA_ARGS__)
#define nm_log_dbg(domain, ...) nm_log (LOGL_DEBUG, (domain), NULL, NULL, __VA_ARGS__)
#define nm_log_trace(domain, ...) nm_log (LOGL_TRACE, (domain), NULL, NULL, __VA_ARGS__)
//#define _NM_LOG_FUNC G_STRFUNC
#define _NM_LOG_FUNC NULL
......@@ -109,53 +111,84 @@ typedef enum { /*< skip >*/
/* A wrapper for the _nm_log_impl() 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(level, domain, error, ...) \
#define _nm_log(level, domain, error, ifname, con_uuid, ...) \
G_STMT_START { \
_nm_log_impl (__FILE__, __LINE__, \
_NM_LOG_FUNC, \
(level), \
(domain), \
(error), \
(ifname), \
(con_uuid), \
""__VA_ARGS__); \
} G_STMT_END
/* nm_log() only evaluates it's argument list after checking
* whether logging for the given level/domain is enabled. */
#define nm_log(level, domain, ...) \
#define nm_log(level, domain, ifname, con_uuid, ...) \
G_STMT_START { \
if (nm_logging_enabled ((level), (domain))) { \
_nm_log (level, domain, 0, __VA_ARGS__); \
_nm_log (level, domain, 0, ifname, con_uuid, __VA_ARGS__); \
} \
} G_STMT_END
#define _nm_log_ptr(level, domain, self, prefix, ...) \
nm_log ((level), (domain), "%s[%p] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), (prefix) ?: "", self _NM_UTILS_MACRO_REST(__VA_ARGS__))
#define _nm_log_ptr(level, domain, ifname, con_uuid, self, prefix, ...) \
nm_log ((level), \
(domain), \
(ifname), \
(con_uuid), \
"%s[%p] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(prefix) ?: "", \
self _NM_UTILS_MACRO_REST(__VA_ARGS__))
/* log a message for an object (with providing a generic @self pointer) */
#define nm_log_ptr(level, domain, self, prefix, ...) \
#define nm_log_ptr(level, domain, ifname, con_uuid, self, prefix, ...) \
G_STMT_START { \
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare") \
if ((level) <= LOGL_DEBUG) { \
_nm_log_ptr ((level), (domain), (self), (prefix), __VA_ARGS__); \
_nm_log_ptr ((level), \
(domain), \
(ifname), \
(con_uuid), \
(self), \
(prefix), \
__VA_ARGS__); \
} else { \
const char *__prefix = (prefix); \
\
nm_log ((level), (domain), "%s%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), __prefix ?: "", __prefix ? " " : "" _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
nm_log ((level), \
(domain), \
(ifname), \
(con_uuid), \
"%s%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix ?: "", \
__prefix ? " " : "" _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
NM_PRAGMA_WARNING_REENABLE \
} G_STMT_END
#define _nm_log_obj(level, domain, self, prefix, ...) \
_nm_log_ptr ((level), (domain), (self), prefix, __VA_ARGS__)
#define _nm_log_obj(level, domain, ifname, con_uuid, self, prefix, ...) \
_nm_log_ptr ((level), \
(domain), \
(ifname), \
(con_uuid), \
(self), \
prefix, \
__VA_ARGS__)
/* log a message for an object (with providing a @self pointer to a GObject).
* Contrary to nm_log_ptr(), @self must be a GObject type (or %NULL).
* As of now, nm_log_obj() is identical to nm_log_ptr(), but we might change that */
#define nm_log_obj(level, domain, self, prefix, ...) \
nm_log_ptr ((level), (domain), (self), prefix, __VA_ARGS__)
#define nm_log_obj(level, domain, ifname, con_uuid, self, prefix, ...) \
nm_log_ptr ((level), \
(domain), \
(ifname), \
(con_uuid), \
(self), \
prefix, \
__VA_ARGS__)
void _nm_log_impl (const char *file,
guint line,
......@@ -163,8 +196,10 @@ void _nm_log_impl (const char *file,
NMLogLevel level,
NMLogDomain domain,
int error,
const char *ifname,
const char *con_uuid,
const char *fmt,
...) _nm_printf (7, 8);
...) _nm_printf (9, 10);
const char *nm_logging_level_to_string (void);
const char *nm_logging_domains_to_string (void);
......@@ -277,7 +312,7 @@ extern void (*_nm_logging_clear_platform_logging_cache) (void);
#define __NMLOG_DEFAULT(level, domain, prefix, ...) \
G_STMT_START { \
nm_log ((level), (domain), \
nm_log ((level), (domain), NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(prefix) \
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
......@@ -285,7 +320,7 @@ extern void (*_nm_logging_clear_platform_logging_cache) (void);
#define __NMLOG_DEFAULT_WITH_ADDR(level, domain, prefix, ...) \
G_STMT_START { \
nm_log ((level), (domain), \
nm_log ((level), (domain), NULL, NULL, \
"%s[%p]: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(prefix), \
(self) \
......
......@@ -228,7 +228,7 @@ NM_DEFINE_SINGLETON_INSTANCE (NMManager);
const NMManager *const __self = (self); \
char __sbuf[32]; \
\
_nm_log (__level, __domain, 0, \
_nm_log (__level, __domain, 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(__self && __self != singleton_instance) \
......
......@@ -123,7 +123,7 @@ _PRIV_TO_SELF (NMPolicyPrivate *priv)
#define _NMLOG_PREFIX_NAME "policy"
#define _NMLOG(level, domain, ...) \
G_STMT_START { \
nm_log ((level), (domain), \
nm_log ((level), (domain), NULL, NULL, \
"%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME": " \
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
......
......@@ -160,7 +160,7 @@ static const VTableIP vtable_v4, vtable_v6;
g_snprintf (__prefix, sizeof (__prefix), "%s%c[%p]", _NMLOG_PREFIX_NAME, __ch, (self)); \
else \
__prefix[NM_STRLEN (_NMLOG_PREFIX_NAME)] = __ch; \
_nm_log ((level), (__domain), 0, \
_nm_log ((level), (__domain), 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
......
......@@ -88,7 +88,7 @@ G_DEFINE_TYPE (NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM)
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \
__p_prefix = __prefix; \
} \
_nm_log (__level, __domain, 0, \
_nm_log (__level, __domain, 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
} \
......
......@@ -151,7 +151,7 @@
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \
__p_prefix = __prefix; \
} \
_nm_log (__level, __domain, __errsv, \
_nm_log (__level, __domain, __errsv, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
} G_STMT_END
......
......@@ -68,7 +68,7 @@ G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPRoute, network_ptr) == G_STRUCT_OF
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _NMLOG_PREFIX_NAME, __self); \
__p_prefix = __prefix; \
} \
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
} \
......
......@@ -75,7 +75,7 @@ __ns_types_to_str (int ns_types, int ns_types_already_set, char *buf, gsize len)
NMPNetns *_netns = (netns); \
char _sbuf[20]; \
\
_nm_log (_level, _NMLOG_DOMAIN, 0, \
_nm_log (_level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(_netns ? nm_sprintf_buf (_sbuf, "[%p]", _netns) : "") \
......
......@@ -41,7 +41,7 @@
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
const NMPObject *const __obj = (obj); \
\
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"nmp-object[%p/%s]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__obj, \
(__obj ? NMP_OBJECT_GET_CLASS (__obj)->obj_type_name : "???") \
......
......@@ -26,7 +26,7 @@
if (nm_logging_enabled (__level, __domain)) { \
gint64 _ts = nm_utils_get_monotonic_timestamp_ns (); \
\
_nm_log (__level, __domain, 0, \
_nm_log (__level, __domain, 0, NULL, NULL, \
"%s[%ld.%09ld]: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
(long) (_ts / NM_UTILS_NS_PER_SECOND), \
......
......@@ -103,7 +103,7 @@ NM_DEFINE_SINGLETON_GETTER (NMAgentManager, nm_agent_manager_get, NM_TYPE_AGENT_
nm_secret_agent_get_description (__agent)); \
} else \
__prefix2[0] = '\0'; \
_nm_log ((level), (_NMLOG_DOMAIN), 0, \
_nm_log ((level), (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix1, __prefix2 _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
......
......@@ -87,7 +87,7 @@ G_DEFINE_TYPE (NMSecretAgent, nm_secret_agent, G_TYPE_OBJECT)
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", ""_NMLOG_PREFIX_NAME"", (self)); \
else \
g_strlcpy (__prefix, _NMLOG_PREFIX_NAME, sizeof (__prefix)); \
_nm_log ((level), (_NMLOG_DOMAIN), 0, \
_nm_log ((level), (_NMLOG_DOMAIN), 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
__prefix _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
} \
......
......@@ -138,7 +138,7 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_E
g_snprintf (__prefix, sizeof (__prefix), "%s[%p%s%s]", _NMLOG_PREFIX_NAME, self, __uuid ? "," : "", __uuid ? __uuid : ""); \
__p_prefix = __prefix; \
} \
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
} \
......
......@@ -98,7 +98,7 @@ NM_DEFINE_SINGLETON_GETTER (SettingsPluginIfcfg, settings_plugin_ifcfg_get, SETT
#define _NMLOG_DOMAIN LOGD_SETTINGS
#define _NMLOG(level, ...) \
G_STMT_START { \
nm_log ((level), (_NMLOG_DOMAIN), \
nm_log ((level), (_NMLOG_DOMAIN), NULL, NULL, \
"%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
"ifcfg-rh: " \
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
......
......@@ -66,7 +66,7 @@
#define _NMLOG_PREFIX_NAME "ifcfg-rh"
#define _NMLOG(level, ...) \
G_STMT_START { \
nm_log ((level), (_NMLOG_DOMAIN), \
nm_log ((level), (_NMLOG_DOMAIN), NULL, NULL, \
"%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
_NMLOG_PREFIX_NAME": " \
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
......
......@@ -60,7 +60,7 @@
#define _NMLOG_PREFIX_NAME "ifcfg-rh"
#define _NMLOG(level, ...) \
G_STMT_START { \
nm_log ((level), (_NMLOG_DOMAIN), \
nm_log ((level), (_NMLOG_DOMAIN), NULL, NULL, \
"%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
_NMLOG_PREFIX_NAME": " \
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
......
......@@ -77,7 +77,7 @@ G_DEFINE_TYPE_EXTENDED (NMSKeyfilePlugin, nms_keyfile_plugin, G_TYPE_OBJECT, 0,
#define _NMLOG_PREFIX_NAME "keyfile"
#define _NMLOG_DOMAIN LOGD_SETTINGS
#define _NMLOG(level, ...) \
nm_log ((level), _NMLOG_DOMAIN, \
nm_log ((level), _NMLOG_DOMAIN, NULL, NULL, \
"%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME": " \
_NM_UTILS_MACRO_REST (__VA_ARGS__))
......
......@@ -87,7 +87,7 @@ _handler_read (GKeyFile *keyfile,
else
level = LOGL_INFO;
nm_log (level, LOGD_SETTINGS, "keyfile: %s",
nm_log (level, LOGD_SETTINGS, NULL, NULL, "keyfile: %s",
_fmt_warn (warn_data->group, warn_data->setting,
warn_data->property_name, warn_data->message,
&message_free));
......
......@@ -136,7 +136,7 @@ G_DEFINE_TYPE (NMSupplicantInterface, nm_supplicant_interface, G_TYPE_OBJECT)
G_STMT_START { \
char _sbuf[64]; \
\
nm_log ((level), _NMLOG_DOMAIN, \
nm_log ((level), _NMLOG_DOMAIN, NULL, NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
((self) \
......
......@@ -56,7 +56,7 @@ _slog_level_to_nm (int slevel)
if (nm_logging_enabled (_nm_l, LOGD_SYSTEMD)) { \
const char *_nm_location = strrchr ((""file), '/'); \
\
_nm_log_impl (_nm_location ? _nm_location + 1 : (""file), (line), (func), _nm_l, LOGD_DHCP, _nm_e, ("%s"format), "libsystemd: ", ## __VA_ARGS__); \
_nm_log_impl (_nm_location ? _nm_location + 1 : (""file), (line), (func), _nm_l, LOGD_DHCP, _nm_e, NULL, NULL, ("%s"format), "libsystemd: ", ## __VA_ARGS__); \
} \
(_nm_e > 0 ? -_nm_e : _nm_e); \
})
......
......@@ -228,7 +228,7 @@ test_nm_utils_log_connection_diff (void)
* early without doing anything. Hence, in the normal testing, this test does nothing.
* It only gets interesting, when run verbosely with NMTST_DEBUG=debug ... */
nm_log (LOGL_DEBUG, LOGD_CORE, "START TEST test_nm_utils_log_connection_diff...");
nm_log (LOGL_DEBUG, LOGD_CORE, NULL, NULL, "START TEST test_nm_utils_log_connection_diff...");
connection = nm_simple_connection_new ();
nm_connection_add_setting (connection, nm_setting_connection_new ());
......
......@@ -54,6 +54,8 @@ _nm_log_impl (const char *file,
NMLogLevel level,
NMLogDomain domain,
int error,
const char *ifname,
const char *con_uuid,
const char *fmt,
...)
{
......
......@@ -240,7 +240,7 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self)
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
char __prefix[__NMLOG_prefix_buf_len]; \
\
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__LOG_create_prefix (__prefix, self) \
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment