device: improve logging messages

Add a "device" prefix to the messages.
This commit is contained in:
Beniamino Galvani 2016-03-03 09:20:00 +01:00
parent 392c3909d8
commit 67473283ca
3 changed files with 17 additions and 15 deletions

View file

@ -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), \
nm_log_obj ((level), (domain), (self), "device", \
"(%s): " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
(self) ? str_if_set (nm_device_get_iface (_nm_device_log_self_to_device (self)), "(null)") : "(none)" \
_NM_UTILS_MACRO_REST(__VA_ARGS__))

View file

@ -3164,7 +3164,7 @@ recheck_available (gpointer user_data)
}
if (new_state > NM_DEVICE_STATE_UNKNOWN) {
_LOGD (LOGD_DEVICE, "device is %savailable, %s %s",
_LOGD (LOGD_DEVICE, "is %savailable, %s %s",
now_available ? "" : "not ",
new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to",
state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state));
@ -8434,7 +8434,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
_LOGD (LOGD_HW, "bringing up device.");
_LOGD (LOGD_HW, "bringing up device");
if (NM_DEVICE_GET_CLASS (self)->bring_up) {
if (!NM_DEVICE_GET_CLASS (self)->bring_up (self, no_firmware))
@ -8508,7 +8508,7 @@ nm_device_take_down (NMDevice *self, gboolean block)
g_return_if_fail (NM_IS_DEVICE (self));
_LOGD (LOGD_HW, "taking down device.");
_LOGD (LOGD_HW, "taking down device");
if (NM_DEVICE_GET_CLASS (self)->take_down) {
if (!NM_DEVICE_GET_CLASS (self)->take_down (self))
@ -10355,7 +10355,7 @@ _set_state_full (NMDevice *self,
if ( (priv->state == state)
&& ( state != NM_DEVICE_STATE_UNAVAILABLE
|| !priv->firmware_missing)) {
_LOGD (LOGD_DEVICE, "device state change: %s -> %s (reason '%s') [%d %d %d]%s",
_LOGD (LOGD_DEVICE, "state change: %s -> %s (reason '%s') [%d %d %d]%s",
state_to_string (old_state),
state_to_string (state),
reason_to_string (reason),
@ -10366,7 +10366,7 @@ _set_state_full (NMDevice *self,
return;
}
_LOGI (LOGD_DEVICE, "device state change: %s -> %s (reason '%s') [%d %d %d]",
_LOGI (LOGD_DEVICE, "state change: %s -> %s (reason '%s') [%d %d %d]",
state_to_string (old_state),
state_to_string (state),
reason_to_string (reason),

View file

@ -118,30 +118,32 @@ typedef enum { /*< skip >*/
} G_STMT_END
#define _nm_log_ptr(level, domain, self, ...) \
nm_log ((level), (domain), "[%p] " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), self _NM_UTILS_MACRO_REST(__VA_ARGS__))
#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__))
/* log a message for an object (with providing a generic @self pointer) */
#define nm_log_ptr(level, domain, self, ...) \
#define nm_log_ptr(level, domain, self, prefix, ...) \
G_STMT_START { \
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare") \
if ((level) <= LOGL_DEBUG) { \
_nm_log_ptr ((level), (domain), (self), __VA_ARGS__); \
_nm_log_ptr ((level), (domain), (self), (prefix), __VA_ARGS__); \
} else { \
nm_log ((level), (domain), __VA_ARGS__); \
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_PRAGMA_WARNING_REENABLE \
} G_STMT_END
#define _nm_log_obj(level, domain, self, ...) \
_nm_log_ptr ((level), (domain), (self), __VA_ARGS__)
#define _nm_log_obj(level, domain, self, prefix, ...) \
_nm_log_ptr ((level), (domain), (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, ...) \
nm_log_ptr ((level), (domain), (self), __VA_ARGS__)
#define nm_log_obj(level, domain, self, prefix, ...) \
nm_log_ptr ((level), (domain), (self), prefix, __VA_ARGS__)
void _nm_log_impl (const char *file,