mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 15:50:36 +01:00
merge: branch 'lr/log-hints-1'
Adds NM_DEVICE and NM_CONNECTION tags to journal in various places. When we're well covered, we can add hints to inspect relevant logs to the client (which this merge does not). https://bugzilla.gnome.org/show_bug.cgi?id=779536
This commit is contained in:
commit
996e081af3
46 changed files with 163 additions and 111 deletions
|
|
@ -81,13 +81,14 @@ G_DEFINE_TYPE (NMArpingManager, nm_arping_manager, G_TYPE_OBJECT)
|
|||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
char _sbuf[64]; \
|
||||
int _ifindex = (self) ? NM_ARPING_MANAGER_GET_PRIVATE (self)->ifindex : 0; \
|
||||
\
|
||||
nm_log ((level), _NMLOG_DOMAIN, \
|
||||
nm_platform_link_get_name (NM_PLATFORM_GET, _ifindex), \
|
||||
NULL, \
|
||||
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME, \
|
||||
self ? nm_sprintf_buf (_sbuf, "[%p,%d]", \
|
||||
self, \
|
||||
NM_ARPING_MANAGER_GET_PRIVATE (self)->ifindex) : "" \
|
||||
self ? nm_sprintf_buf (_sbuf, "[%p,%d]", self, _ifindex) : "" \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} G_STMT_END
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ _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), \
|
||||
(self) ? nm_device_get_iface (_nm_device_log_self_to_device (self)) : 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__))
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ typedef struct {
|
|||
int _ifindex = (self) ? NM_LLDP_LISTENER_GET_PRIVATE (self)->ifindex : 0; \
|
||||
\
|
||||
_nm_log (_level, _NMLOG_DOMAIN, 0, \
|
||||
nm_platform_link_get_name (NM_PLATFORM_GET, _ifindex), \
|
||||
NULL, \
|
||||
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME, \
|
||||
((_ifindex > 0) \
|
||||
|
|
|
|||
|
|
@ -119,7 +119,10 @@ 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, \
|
||||
((__self && __self->_priv.ctx) \
|
||||
? nm_connection_get_uuid (__self->_priv.ctx->connection) \
|
||||
: 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, __ifname, 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, __ifname, 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 \
|
||||
|
|
|
|||
11
src/main.c
11
src/main.c
|
|
@ -348,12 +348,11 @@ main (int argc, char *argv[])
|
|||
/* Set up unix signal handling - before creating threads, but after daemonizing! */
|
||||
nm_main_utils_setup_signals (main_loop);
|
||||
|
||||
nm_logging_syslog_openlog (nm_config_get_is_debug (config)
|
||||
? "debug"
|
||||
: nm_config_data_get_value_cached (NM_CONFIG_GET_DATA_ORIG,
|
||||
NM_CONFIG_KEYFILE_GROUP_LOGGING,
|
||||
NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND,
|
||||
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY));
|
||||
nm_logging_syslog_openlog (nm_config_data_get_value_cached (NM_CONFIG_GET_DATA_ORIG,
|
||||
NM_CONFIG_KEYFILE_GROUP_LOGGING,
|
||||
NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND,
|
||||
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY),
|
||||
nm_config_get_is_debug (config));
|
||||
|
||||
nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting...");
|
||||
|
||||
|
|
|
|||
|
|
@ -58,16 +58,14 @@ gboolean nm_ndisc_add_dns_domain (NMNDisc *ndisc, const NMNDiscDNSDoma
|
|||
if (nm_logging_enabled (__level, __domain)) { \
|
||||
NMNDisc *const __self = (self); \
|
||||
char __prefix[64]; \
|
||||
const char *__ifname = __self ? nm_ndisc_get_ifname (__self) : NULL; \
|
||||
\
|
||||
_nm_log (__level, __domain, 0, \
|
||||
_nm_log (__level, __domain, 0, __ifname, NULL, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
(__self \
|
||||
? ({ \
|
||||
const char *__ifname = nm_ndisc_get_ifname (__self); \
|
||||
nm_sprintf_buf (__prefix, "%s[%p,%s%s%s]", \
|
||||
_NMLOG_PREFIX_NAME, __self, \
|
||||
NM_PRINT_FMT_QUOTE_STRING (__ifname)); \
|
||||
}) \
|
||||
? nm_sprintf_buf (__prefix, "%s[%p,%s%s%s]", \
|
||||
_NMLOG_PREFIX_NAME, __self, \
|
||||
NM_PRINT_FMT_QUOTE_STRING (__ifname)) \
|
||||
: _NMLOG_PREFIX_NAME) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
|
|
|
|||
|
|
@ -121,8 +121,12 @@ static void _set_activation_type (NMActiveConnection *self,
|
|||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
char _sbuf[64]; \
|
||||
NMDevice *_device = (self) ? NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->device : NULL; \
|
||||
NMConnection *_applied_connection = _device ? NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->applied_connection : NULL; \
|
||||
\
|
||||
nm_log ((level), _NMLOG_DOMAIN, \
|
||||
(_device) ? nm_device_get_iface (_device) : NULL, \
|
||||
(_applied_connection) ? nm_connection_get_uuid (_applied_connection) : 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), global_opt.ifname, NULL, \
|
||||
"iface-helper: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__))
|
||||
|
||||
|
|
@ -432,9 +432,8 @@ main (int argc, char *argv[])
|
|||
gl.main_loop = g_main_loop_new (NULL, FALSE);
|
||||
setup_signals ();
|
||||
|
||||
nm_logging_syslog_openlog (global_opt.logging_backend
|
||||
? global_opt.logging_backend
|
||||
: (global_opt.debug ? "debug" : NULL));
|
||||
nm_logging_syslog_openlog (global_opt.logging_backend,
|
||||
global_opt.debug);
|
||||
|
||||
_LOGI (LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting...");
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ static struct Global {
|
|||
NMLogLevel log_level;
|
||||
bool uses_syslog:1;
|
||||
bool syslog_identifier_initialized:1;
|
||||
bool debug_stderr:1;
|
||||
const char *prefix;
|
||||
const char *syslog_identifier;
|
||||
enum {
|
||||
|
|
@ -593,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,
|
||||
...)
|
||||
{
|
||||
|
|
@ -630,6 +633,9 @@ _nm_log_impl (const char *file,
|
|||
|
||||
g_get_current_time (&tv);
|
||||
|
||||
if (global.debug_stderr)
|
||||
g_printerr (MESSAGE_FMT"\n", MESSAGE_ARG (global, tv, msg));
|
||||
|
||||
switch (global.log_backend) {
|
||||
#if SYSTEMD_JOURNAL
|
||||
case LOG_BACKEND_JOURNAL:
|
||||
|
|
@ -638,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;
|
||||
|
||||
|
|
@ -700,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)]);
|
||||
|
|
@ -817,7 +827,7 @@ nm_logging_set_prefix (const char *format, ...)
|
|||
}
|
||||
|
||||
void
|
||||
nm_logging_syslog_openlog (const char *logging_backend)
|
||||
nm_logging_syslog_openlog (const char *logging_backend, gboolean debug)
|
||||
{
|
||||
if (global.log_backend != LOG_BACKEND_GLIB)
|
||||
g_return_if_reached ();
|
||||
|
|
@ -825,21 +835,21 @@ nm_logging_syslog_openlog (const char *logging_backend)
|
|||
if (!logging_backend)
|
||||
logging_backend = ""NM_CONFIG_DEFAULT_LOGGING_BACKEND;
|
||||
|
||||
if (strcmp (logging_backend, "debug") == 0) {
|
||||
global.log_backend = LOG_BACKEND_SYSLOG;
|
||||
openlog (syslog_identifier_domain (&global), LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
|
||||
#if SYSTEMD_JOURNAL
|
||||
} else if (strcmp (logging_backend, "syslog") != 0) {
|
||||
if (strcmp (logging_backend, "syslog") != 0) {
|
||||
global.log_backend = LOG_BACKEND_JOURNAL;
|
||||
global.uses_syslog = TRUE;
|
||||
global.debug_stderr = debug;
|
||||
|
||||
/* ensure we read a monotonic timestamp. Reading the timestamp the first
|
||||
* time causes a logging message. We don't want to do that during _nm_log_impl. */
|
||||
nm_utils_get_monotonic_timestamp_ns ();
|
||||
} else
|
||||
#endif
|
||||
} else {
|
||||
{
|
||||
global.log_backend = LOG_BACKEND_SYSLOG;
|
||||
global.uses_syslog = TRUE;
|
||||
global.debug_stderr = debug;
|
||||
openlog (syslog_identifier_domain (&global), LOG_PID, LOG_DAEMON);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -191,7 +226,7 @@ gboolean nm_logging_setup (const char *level,
|
|||
void nm_logging_set_syslog_identifier (const char *domain);
|
||||
void nm_logging_set_prefix (const char *format, ...) _nm_printf (1, 2);
|
||||
|
||||
void nm_logging_syslog_openlog (const char *logging_backend);
|
||||
void nm_logging_syslog_openlog (const char *logging_backend, gboolean debug);
|
||||
gboolean nm_logging_syslog_enabled (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), \
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#define _NMLOG_PREFIX_NAME "wifi-nl80211"
|
||||
#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__)); \
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ struct iw_range_with_scan_capa
|
|||
#define _NMLOG_PREFIX_NAME "wifi-wext"
|
||||
#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__)); \
|
||||
|
|
|
|||
|
|
@ -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__)); \
|
||||
} \
|
||||
|
|
|
|||
|
|
@ -131,14 +131,13 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_E
|
|||
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
|
||||
char __prefix[128]; \
|
||||
const char *__p_prefix = _NMLOG_PREFIX_NAME; \
|
||||
const char *__uuid = (self) ? nm_settings_connection_get_uuid (self) : NULL; \
|
||||
\
|
||||
if (self) { \
|
||||
const char *__uuid = nm_settings_connection_get_uuid (self); \
|
||||
\
|
||||
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, __uuid, \
|
||||
"%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,9 @@ _handler_read (GKeyFile *keyfile,
|
|||
else
|
||||
level = LOGL_INFO;
|
||||
|
||||
nm_log (level, LOGD_SETTINGS, "keyfile: %s",
|
||||
nm_log (level, LOGD_SETTINGS, NULL,
|
||||
nm_connection_get_uuid (connection),
|
||||
"keyfile: %s",
|
||||
_fmt_warn (warn_data->group, warn_data->setting,
|
||||
warn_data->property_name, warn_data->message,
|
||||
&message_free));
|
||||
|
|
|
|||
|
|
@ -135,16 +135,12 @@ G_DEFINE_TYPE (NMSupplicantInterface, nm_supplicant_interface, G_TYPE_OBJECT)
|
|||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
char _sbuf[64]; \
|
||||
const char *__ifname = self ? NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev : NULL; \
|
||||
\
|
||||
nm_log ((level), _NMLOG_DOMAIN, \
|
||||
nm_log ((level), _NMLOG_DOMAIN, __ifname, NULL, \
|
||||
"%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME, \
|
||||
((self) \
|
||||
? nm_sprintf_buf (_sbuf, \
|
||||
"[%p,%s]", \
|
||||
(self), \
|
||||
NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->dev) \
|
||||
: "") \
|
||||
((self) ? nm_sprintf_buf (_sbuf, "[%p,%s]", (self), __ifname) : "") \
|
||||
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
||||
} G_STMT_END
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
...)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,18 +200,15 @@ static void _set_vpn_state (NMVpnConnection *self,
|
|||
#define __NMLOG_prefix_buf_len 128
|
||||
|
||||
static const char *
|
||||
__LOG_create_prefix (char *buf, NMVpnConnection *self)
|
||||
__LOG_create_prefix (char *buf, NMVpnConnection *self, NMConnection *con)
|
||||
{
|
||||
NMVpnConnectionPrivate *priv;
|
||||
NMConnection *con;
|
||||
const char *id;
|
||||
|
||||
if (!self)
|
||||
return _NMLOG_PREFIX_NAME;
|
||||
|
||||
priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
|
||||
|
||||
con = NM_CONNECTION (_get_settings_connection (self, TRUE));
|
||||
id = con ? nm_connection_get_id (con) : NULL;
|
||||
|
||||
g_snprintf (buf, __NMLOG_prefix_buf_len,
|
||||
|
|
@ -236,13 +233,16 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self)
|
|||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
const NMLogLevel __level = (level); \
|
||||
NMConnection *__con = (self) ? (NMConnection *) _get_settings_connection (self, TRUE) : NULL; \
|
||||
\
|
||||
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
|
||||
char __prefix[__NMLOG_prefix_buf_len]; \
|
||||
\
|
||||
_nm_log (__level, _NMLOG_DOMAIN, 0, \
|
||||
(self) ? NM_VPN_CONNECTION_GET_PRIVATE (self)->ip_iface : NULL, \
|
||||
(__con) ? nm_connection_get_uuid (__con) : NULL, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
__LOG_create_prefix (__prefix, self) \
|
||||
__LOG_create_prefix (__prefix, (self), __con) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue