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

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)]);
......
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