logging: update nm-manager.c logging

This commit is contained in:
Dan Williams 2010-04-06 16:20:11 -07:00
parent 6e97fc4441
commit 28664e80fe

View file

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2009 Novell, Inc.
* Copyright (C) 2007 - 2009 Red Hat, Inc.
* Copyright (C) 2007 - 2010 Red Hat, Inc.
*/
#include <netinet/ether.h>
@ -26,7 +26,7 @@
#include "nm-glib-compat.h"
#include "nm-manager.h"
#include "nm-utils.h"
#include "nm-logging.h"
#include "nm-dbus-manager.h"
#include "nm-vpn-manager.h"
#include "nm-modem-manager.h"
@ -341,8 +341,7 @@ modem_added (NMModemManager *modem_manager,
* by the Bluetooth code during the connection process.
*/
if (driver && !strcmp (driver, "bluetooth")) {
g_message ("%s: ignoring modem '%s' (no associated Bluetooth device)",
__func__, ip_iface);
nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", ip_iface);
return;
}
@ -352,7 +351,7 @@ modem_added (NMModemManager *modem_manager,
else if (NM_IS_MODEM_CDMA (modem))
device = nm_device_cdma_new (NM_MODEM_CDMA (modem), driver);
else
g_message ("%s: unhandled modem '%s'", __func__, ip_iface);
nm_log_info (LOGD_MB, "unhandled modem '%s'", ip_iface);
if (device)
add_device (self, device);
@ -488,7 +487,7 @@ aipd_handle_event (DBusGProxy *proxy,
gboolean handled = FALSE;
if (!event || !iface) {
nm_warning ("Incomplete message received from avahi-autoipd");
nm_log_warn (LOGD_AUTOIP4, "incomplete message received from avahi-autoipd");
return;
}
@ -496,7 +495,7 @@ aipd_handle_event (DBusGProxy *proxy,
&& (strcmp (event, "CONFLICT") != 0)
&& (strcmp (event, "UNBIND") != 0)
&& (strcmp (event, "STOP") != 0)) {
nm_warning ("Unknown event '%s' received from avahi-autoipd", event);
nm_log_warn (LOGD_AUTOIP4, "unknown event '%s' received from avahi-autoipd", event);
return;
}
@ -511,7 +510,7 @@ aipd_handle_event (DBusGProxy *proxy,
}
if (!handled)
nm_warning ("Unhandled avahi-autoipd event for '%s'", iface);
nm_log_warn (LOGD_AUTOIP4, "(%s): unhandled avahi-autoipd event", iface);
}
static const char *
@ -693,7 +692,8 @@ user_connection_get_settings_cb (DBusGProxy *proxy,
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
G_TYPE_INVALID)) {
nm_warning ("Couldn't retrieve connection settings: %s.", err->message);
nm_log_info (LOGD_USER_SET, "couldn't retrieve connection settings: %s.",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
goto out;
}
@ -708,10 +708,9 @@ user_connection_get_settings_cb (DBusGProxy *proxy,
connection = nm_connection_new_from_hash (settings, &error);
if (connection == NULL) {
nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
nm_log_warn (LOGD_USER_SET, "invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
g_error_free (error);
goto out;
}
@ -754,7 +753,7 @@ user_connection_get_settings_cb (DBusGProxy *proxy,
}
} else {
// FIXME: merge settings? or just replace?
nm_warning ("%s (#%d): implement merge settings", __func__, __LINE__);
nm_log_dbg (LOGD_USER_SET, "implement merge settings");
}
out:
@ -802,10 +801,9 @@ user_connection_updated_cb (DBusGProxy *proxy,
new_connection = nm_connection_new_from_hash (settings, &error);
if (!new_connection) {
/* New connection invalid, remove existing connection */
nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
nm_log_warn (LOGD_USER_SET, "invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
g_error_free (error);
remove_connection (manager, old_connection, priv->user_connections);
return;
@ -842,7 +840,7 @@ user_internal_new_connection_cb (DBusGProxy *proxy,
path,
NM_DBUS_IFACE_SETTINGS_CONNECTION);
if (!con_proxy) {
nm_warning ("Error: could not init user connection proxy");
nm_log_err (LOGD_USER_SET, "could not init user connection proxy");
return;
}
@ -888,7 +886,8 @@ user_list_connections_cb (DBusGProxy *proxy,
if (!dbus_g_proxy_end_call (proxy, call_id, &err,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &ops,
G_TYPE_INVALID)) {
nm_warning ("Couldn't retrieve connections: %s.", err->message);
nm_log_warn (LOGD_USER_SET, "couldn't retrieve connections: %s",
err && err->message ? err->message : "(unknown)");
g_error_free (err);
goto out;
}
@ -934,7 +933,7 @@ user_query_connections (NMManager *manager)
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
if (!priv->user_proxy) {
nm_warning ("Error: could not init settings proxy");
nm_log_err (LOGD_USER_SET, "could not init user settings proxy");
return;
}
@ -977,16 +976,15 @@ system_connection_updated_cb (NMSettingsConnectionInterface *connection,
if (!existing)
return;
if (existing != connection) {
g_warning ("%s: existing connection didn't matched updated.", __func__);
nm_log_warn (LOGD_SYS_SET, "existing connection didn't matched updated.");
return;
}
if (!nm_connection_verify (NM_CONNECTION (existing), &error)) {
/* Updated connection invalid, remove existing connection */
nm_warning ("%s: Invalid connection: '%s' / '%s' invalid: %d",
__func__,
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
nm_log_warn (LOGD_SYS_SET, "invalid connection: '%s' / '%s' invalid: %d",
g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),
error->message, error->code);
g_error_free (error);
remove_connection (manager, NM_CONNECTION (existing), priv->system_connections);
return;
@ -1228,10 +1226,10 @@ manager_set_radio_enabled (NMManager *manager,
"main", rstate->key,
G_TYPE_BOOLEAN, (gpointer) &enabled,
&error)) {
g_warning ("Writing to state file %s failed: (%d) %s.",
priv->state_file,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
nm_log_warn (LOGD_CORE, "writing to state file %s failed: (%d) %s.",
priv->state_file,
error ? error->code : -1,
(error && error->message) ? error->message : "unknown");
}
}
@ -1401,9 +1399,9 @@ manager_rfkill_update_one_type (NMManager *self,
}
if (new_he != rstate->hw_enabled) {
nm_info ("%s now %s by radio killswitch",
rstate->desc,
(new_e && new_he) ? "enabled" : "disabled");
nm_log_info (LOGD_RFKILL, "%s now %s by radio killswitch",
rstate->desc,
(new_e && new_he) ? "enabled" : "disabled");
rstate->hw_enabled = new_he;
g_object_notify (G_OBJECT (self), rstate->hw_prop);
@ -1510,14 +1508,14 @@ add_device (NMManager *self, NMDevice *device)
driver = nm_device_get_driver (device);
if (!driver)
driver = "unknown";
nm_info ("(%s): new %s device (driver: '%s')", iface, type_desc, driver);
nm_log_info (LOGD_HW, "(%s): new %s device (driver: '%s')", iface, type_desc, driver);
path = g_strdup_printf ("/org/freedesktop/NetworkManager/Devices/%d", devcount++);
nm_device_set_path (device, path);
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (priv->dbus_mgr),
path,
G_OBJECT (device));
nm_info ("(%s): exported as %s", iface, path);
nm_log_info (LOGD_CORE, "(%s): exported as %s", iface, path);
g_free (path);
/* Check if we should assume the device's active connection by matching its
@ -1557,11 +1555,11 @@ add_device (NMManager *self, NMDevice *device)
if (ac_path)
g_object_notify (G_OBJECT (self), NM_MANAGER_ACTIVE_CONNECTIONS);
else {
nm_warning ("Assumed connection (%d) %s failed to activate: (%d) %s",
nm_connection_get_scope (existing),
nm_connection_get_path (existing),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
nm_log_warn (LOGD_CORE, "assumed connection (%d) %s failed to activate: (%d) %s",
nm_connection_get_scope (existing),
nm_connection_get_path (existing),
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_error_free (error);
}
}
@ -1710,13 +1708,12 @@ bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
device = nm_device_bt_new (object_path, bdaddr, name, capabilities, FALSE);
if (device) {
g_message ("%s: BT device %s (%s) added (%s%s%s)",
__func__,
name,
bdaddr,
has_dun ? "DUN" : "",
has_dun && has_nap ? " " : "",
has_nap ? "NAP" : "");
nm_log_info (LOGD_HW, "BT device %s (%s) added (%s%s%s)",
name,
bdaddr,
has_dun ? "DUN" : "",
has_dun && has_nap ? " " : "",
has_nap ? "NAP" : "");
add_device (manager, device);
}
@ -1735,7 +1732,7 @@ bluez_manager_bdaddr_removed_cb (NMBluezManager *bluez_mgr,
g_return_if_fail (bdaddr != NULL);
g_return_if_fail (object_path != NULL);
g_message ("%s: BT device %s removed", __func__, bdaddr);
nm_log_info (LOGD_HW, "BT device %s removed", bdaddr);
for (iter = priv->devices; iter; iter = iter->next) {
NMDevice *device = NM_DEVICE (iter->data);
@ -2010,7 +2007,7 @@ user_get_secrets (NMManager *self,
nm_connection_get_path (connection),
NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
if (!info->proxy) {
nm_warning ("%s: could not create user connection secrets proxy", __func__);
nm_log_warn (LOGD_USER_SET, "could not create user connection secrets proxy");
g_free (info);
return NULL;
}
@ -2225,8 +2222,8 @@ wait_for_connection_expired (gpointer data)
g_set_error (&error,
NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
"%s", "Connection was not provided by any settings service");
nm_warning ("Connection (%d) %s failed to activate (timeout): (%d) %s",
info->scope, info->connection_path, error->code, error->message);
nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate (timeout): (%d) %s",
info->scope, info->connection_path, error->code, error->message);
dbus_g_method_return_error (info->context, error);
g_error_free (error);
@ -2377,8 +2374,8 @@ connection_added_default_handler (NMManager *manager,
g_object_notify (G_OBJECT (manager), NM_MANAGER_ACTIVE_CONNECTIONS);
} else {
dbus_g_method_return_error (info->context, error);
nm_warning ("Connection (%d) %s failed to activate: (%d) %s",
scope, info->connection_path, error->code, error->message);
nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate: (%d) %s",
scope, info->connection_path, error->code, error->message);
g_error_free (error);
}
@ -2561,8 +2558,8 @@ impl_manager_activate_connection (NMManager *manager,
err:
if (error) {
dbus_g_method_return_error (context, error);
nm_warning ("Connection (%d) %s failed to activate: (%d) %s",
scope, connection_path, error->code, error->message);
nm_log_warn (LOGD_CORE, "connection (%d) %s failed to activate: (%d) %s",
scope, connection_path, error->code, error->message);
g_error_free (error);
}
@ -2656,16 +2653,16 @@ impl_manager_sleep (NMManager *self, gboolean sleep, GError **error)
"main", "NetworkingEnabled",
G_TYPE_BOOLEAN, (gpointer) &networking_enabled,
&err)) {
g_warning ("Writing to state file %s failed: (%d) %s.",
priv->state_file,
err ? err->code : -1,
(err && err->message) ? err->message : "unknown");
nm_log_warn (LOGD_SUSPEND, "writing to state file %s failed: (%d) %s.",
priv->state_file,
err ? err->code : -1,
(err && err->message) ? err->message : "unknown");
}
}
if (sleep) {
nm_info ("Sleeping...");
nm_log_info (LOGD_SUSPEND, "sleeping...");
/* Just deactivate and down all devices from the device list,
* we'll remove them in 'wake' for speed's sake.
@ -2675,7 +2672,7 @@ impl_manager_sleep (NMManager *self, gboolean sleep, GError **error)
} else {
const GSList *unmanaged_specs;
nm_info ("Waking up...");
nm_log_info (LOGD_SUSPEND, "waking up...");
unmanaged_specs = nm_sysconfig_settings_get_unmanaged_specs (priv->sys_settings);
@ -2798,7 +2795,7 @@ nm_manager_get_connections (NMManager *manager,
else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
g_hash_table_foreach (priv->system_connections, connections_to_slist, &list);
else
nm_warning ("Unknown NMConnectionScope %d", scope);
nm_log_err (LOGD_CORE, "unknown NMConnectionScope %d", scope);
return list;
}
@ -2819,7 +2816,7 @@ nm_manager_get_connection_by_object_path (NMManager *manager,
else if (scope == NM_CONNECTION_SCOPE_SYSTEM)
connection = (NMConnection *) g_hash_table_lookup (priv->system_connections, path);
else
nm_warning ("Unknown NMConnectionScope %d", scope);
nm_log_err (LOGD_CORE, "unknown NMConnectionScope %d", scope);
return connection;
}
@ -2862,10 +2859,10 @@ nm_manager_start (NMManager *self)
}
rstate->hw_enabled = hw_enabled;
nm_info ("%s %s by radio killswitch; %s by state file",
rstate->desc,
(rstate->hw_enabled && enabled) ? "enabled" : "disabled",
(rstate->enabled) ? "enabled" : "disabled");
nm_log_info (LOGD_RFKILL, "%s %s by radio killswitch; %s by state file",
rstate->desc,
(rstate->hw_enabled && enabled) ? "enabled" : "disabled",
(rstate->enabled) ? "enabled" : "disabled");
manager_set_radio_enabled (self, rstate, rstate->enabled && enabled);
}
@ -3176,7 +3173,7 @@ nm_manager_init (NMManager *manager)
manager,
NULL);
} else
nm_warning ("%s: could not initialize avahi-autoipd D-Bus proxy", __func__);
nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy");
}
static void