From 0e3432fbeaf2d995fbd26aab682970b824fbe032 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 1 Oct 2013 11:08:31 -0400 Subject: [PATCH] logging: tweak logging-enabled functions Rather than having separate nm_logging_level_enabled() and nm_logging_domain_enabled(), have just nm_logging_enabled() that checks both. --- src/devices/nm-device-team.c | 2 +- src/devices/nm-device-wifi.c | 2 +- src/devices/nm-device.c | 4 ++-- src/dhcp-manager/nm-dhcp-client.c | 4 ++-- src/logging/nm-logging.c | 10 ++-------- src/logging/nm-logging.h | 3 +-- src/nm-properties-changed-signal.c | 2 +- src/ppp-manager/nm-ppp-manager.c | 3 +-- src/settings/nm-settings-connection.c | 2 +- 9 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/devices/nm-device-team.c b/src/devices/nm-device-team.c index 009839acb9..df37cee308 100644 --- a/src/devices/nm-device-team.c +++ b/src/devices/nm-device-team.c @@ -549,7 +549,7 @@ teamd_start (NMDevice *dev, NMSettingTeam *s_team, NMDeviceTeamPrivate *priv) g_ptr_array_add (argv, (gpointer) config); } - if (nm_logging_level_enabled (LOGL_DEBUG)) + if (nm_logging_enabled (LOGL_DEBUG, LOGD_TEAM)) g_ptr_array_add (argv, (gpointer) "-gg"); g_ptr_array_add (argv, NULL); diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index 552746ce4b..d9fd0edf12 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -1633,7 +1633,7 @@ request_wireless_scan (gpointer user_data) ssids = build_hidden_probe_list (self); - if (nm_logging_level_enabled (LOGL_DEBUG)) { + if (nm_logging_enabled (LOGL_DEBUG, LOGD_WIFI_SCAN)) { if (ssids) { guint i; char *foo; diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 21d5f94dcd..61bb2aafa1 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2480,7 +2480,7 @@ aipd_start (NMDevice *self, NMDeviceStateReason *reason) argv[i++] = "--script"; argv[i++] = (char *) nm_device_autoipd_helper_path; - if (nm_logging_level_enabled (LOGL_DEBUG)) + if (nm_logging_enabled (LOGL_DEBUG, LOGD_AUTOIP4)) argv[i++] = "--debug"; argv[i++] = (char *) nm_device_get_ip_iface (self); argv[i++] = NULL; @@ -5047,7 +5047,7 @@ spawn_ping (NMDevice *self, args[6] = str_timeout = g_strdup_printf ("%u", timeout); - if (nm_logging_level_enabled (LOGL_DEBUG)) { + if (nm_logging_enabled (LOGL_DEBUG, log_domain)) { cmd = g_strjoinv (" ", (gchar **) args); nm_log_dbg (log_domain, "(%s): running '%s'", nm_device_get_iface (self), diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index a3dd452a24..4bbcdeb173 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -431,7 +431,7 @@ get_duid (NMDHCPClient *self) duid = generate_duid_from_machine_id (); g_assert (duid); - if (nm_logging_level_enabled (LOGL_DEBUG)) { + if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) { escaped = escape_duid (duid); nm_log_dbg (LOGD_DHCP6, "Generated DUID %s", escaped); g_free (escaped); @@ -469,7 +469,7 @@ nm_dhcp_client_start_ip6 (NMDHCPClient *self, if (!priv->duid) priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self); - if (nm_logging_level_enabled (LOGL_DEBUG)) { + if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP)) { escaped = escape_duid (priv->duid); nm_log_dbg (LOGD_DHCP, "(%s): DHCPv6 DUID is '%s'", priv->iface, escaped); g_free (escaped); diff --git a/src/logging/nm-logging.c b/src/logging/nm-logging.c index 446b15fa50..e13b50a75c 100644 --- a/src/logging/nm-logging.c +++ b/src/logging/nm-logging.c @@ -281,15 +281,9 @@ nm_logging_all_domains_to_string (void) } gboolean -nm_logging_level_enabled (guint32 level) +nm_logging_enabled (guint32 level, guint64 domain) { - return !!(log_level & level); -} - -gboolean -nm_logging_domain_enabled (guint64 domain) -{ - return !!(log_domains & domain); + return !!(log_level & level) && !!(log_domains & domain); } void diff --git a/src/logging/nm-logging.h b/src/logging/nm-logging.h index 07cfbce991..fed7e07270 100644 --- a/src/logging/nm-logging.h +++ b/src/logging/nm-logging.h @@ -109,8 +109,7 @@ void _nm_log (const char *loc, const char *nm_logging_level_to_string (void); char *nm_logging_domains_to_string (void); -gboolean nm_logging_level_enabled (guint32 level); -gboolean nm_logging_domain_enabled (guint64 domain); +gboolean nm_logging_enabled (guint32 level, guint64 domain); const char *nm_logging_all_levels_to_string (void); const char *nm_logging_all_domains_to_string (void); diff --git a/src/nm-properties-changed-signal.c b/src/nm-properties-changed-signal.c index b61b87111b..6e07c25709 100644 --- a/src/nm-properties-changed-signal.c +++ b/src/nm-properties-changed-signal.c @@ -102,7 +102,7 @@ properties_changed (gpointer data) g_assert (info); - if (nm_logging_level_enabled (LOGL_DEBUG)) { + if (nm_logging_enabled (LOGL_DEBUG, LOGD_DBUS_PROPS)) { GString *buf = g_string_new (NULL); g_hash_table_foreach (info->hash, add_to_string, buf); diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index b2f2326bed..7b8493716e 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -831,8 +831,7 @@ create_pppd_cmd_line (NMPPPManager *self, nm_cmd_line_add_string (cmd, ","); ppp_debug = !!getenv ("NM_PPP_DEBUG"); - if ( nm_logging_level_enabled (LOGL_DEBUG) - && nm_logging_domain_enabled (LOGD_PPP)) + if (nm_logging_enabled (LOGL_DEBUG, LOGD_PPP)) ppp_debug = TRUE; if (ppp_debug) diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index c252da5df7..7e0d518a59 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -911,7 +911,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self, if (existing_secrets) g_hash_table_unref (existing_secrets); - if (nm_logging_level_enabled (LOGL_DEBUG)) { + if (nm_logging_enabled (LOGL_DEBUG, LOGD_SETTINGS)) { if (hints) joined_hints = g_strjoinv (",", (char **) hints); nm_log_dbg (LOGD_SETTINGS, "(%s/%s:%u) secrets requested flags 0x%X hints '%s'",