summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-03-04 12:06:51 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2016-03-04 12:06:51 +0100
commit7d00394f402cdc744c3d30efc7f47810396926be (patch)
tree2642ee0f4538268fa2b2fba0cbbb0989f60219b8
parentbb7da812feebc28229e2bf4d3772c35d28b605f7 (diff)
parentd6d9f47a321909205c48fd5b2a275b575a4697ba (diff)
downloadNetworkManager-7d00394f402cdc744c3d30efc7f47810396926be.tar.gz
logging: merge branch 'bg/logging-messages-bgo763040'
Introduce logging helpers where possible, to uniform the format of messages and prepend a tag specifying the module that generated the message, along with other useful information (interface name, ...). https://bugzilla.gnome.org/show_bug.cgi?id=763040
-rw-r--r--src/Makefile.am4
-rw-r--r--src/devices/bluetooth/nm-bluez-manager.c26
-rw-r--r--src/devices/nm-device-logging.h2
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/dhcp-manager/nm-dhcp-client-logging.h48
-rw-r--r--src/dhcp-manager/nm-dhcp-client.c81
-rw-r--r--src/dhcp-manager/nm-dhcp-dhclient.c116
-rw-r--r--src/dhcp-manager/nm-dhcp-dhcpcd.c21
-rw-r--r--src/dhcp-manager/nm-dhcp-systemd.c80
-rw-r--r--src/dnsmasq-manager/nm-dnsmasq-manager.c28
-rw-r--r--src/nm-audit-manager.c22
-rw-r--r--src/nm-bus-manager.c57
-rw-r--r--src/nm-dispatcher.c83
-rw-r--r--src/nm-logging.h20
-rw-r--r--src/nm-policy.c129
-rw-r--r--src/ppp-manager/nm-ppp-manager.c50
-rw-r--r--src/settings/nm-settings.c86
-rw-r--r--src/supplicant-manager/nm-supplicant-manager.c34
18 files changed, 504 insertions, 393 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index eea646a487..0d6457a43b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -287,6 +287,7 @@ libNetworkManager_la_SOURCES = \
\
dhcp-manager/nm-dhcp-client.c \
dhcp-manager/nm-dhcp-client.h \
+ dhcp-manager/nm-dhcp-client-logging.h \
dhcp-manager/nm-dhcp-utils.c \
dhcp-manager/nm-dhcp-utils.h \
dhcp-manager/nm-dhcp-listener.c \
@@ -462,6 +463,8 @@ nm_enum_types_sources = $(filter-out \
%/nm-device-private.h \
%/nm-rdisc-private.h \
%/wifi-utils-private.h \
+ %/nm-dhcp-client-logging.h \
+ %/nm-device-logging.h \
, $(libNetworkManager_la_SOURCES))
BUILT_SOURCES = $(GLIB_GENERATED)
@@ -526,6 +529,7 @@ NetworkManager_LDFLAGS = -rdynamic
libnm_iface_helper_la_SOURCES = \
dhcp-manager/nm-dhcp-client.c \
dhcp-manager/nm-dhcp-client.h \
+ dhcp-manager/nm-dhcp-client-logging.h \
dhcp-manager/nm-dhcp-utils.c \
dhcp-manager/nm-dhcp-utils.h \
dhcp-manager/nm-dhcp-manager.c \
diff --git a/src/devices/bluetooth/nm-bluez-manager.c b/src/devices/bluetooth/nm-bluez-manager.c
index f66b5abe58..766ecc0abc 100644
--- a/src/devices/bluetooth/nm-bluez-manager.c
+++ b/src/devices/bluetooth/nm-bluez-manager.c
@@ -38,6 +38,16 @@
#include "nm-platform.h"
#include "nm-dbus-compat.h"
+#define _NMLOG_DOMAIN LOGD_BT
+#define _NMLOG_PREFIX_NAME "bluez"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
typedef struct {
int bluez_version;
@@ -146,12 +156,12 @@ manager_bdaddr_added_cb (NMBluez4Manager *bluez_mgr,
if (!device)
return;
- nm_log_info (LOGD_BT, "BT device %s (%s) added (%s%s%s)",
- name,
- bdaddr,
- has_dun ? "DUN" : "",
- has_dun && has_nap ? " " : "",
- has_nap ? "NAP" : "");
+ _LOGI ("BT device %s (%s) added (%s%s%s)",
+ name,
+ bdaddr,
+ has_dun ? "DUN" : "",
+ has_dun && has_nap ? " " : "",
+ has_nap ? "NAP" : "");
g_signal_emit_by_name (self, NM_DEVICE_FACTORY_DEVICE_ADDED, device);
g_object_unref (device);
}
@@ -163,7 +173,7 @@ setup_version_number (NMBluezManager *self, int bluez_version)
g_return_if_fail (!priv->bluez_version);
- nm_log_info (LOGD_BT, "use BlueZ version %d", bluez_version);
+ _LOGI ("use BlueZ version %d", bluez_version);
priv->bluez_version = bluez_version;
@@ -235,7 +245,7 @@ check_bluez_and_try_setup_final_step (NMBluezManager *self, int bluez_version, c
setup_bluez5 (self);
break;
default:
- nm_log_dbg (LOGD_BT, "detecting BlueZ version failed: %s", reason);
+ _LOGD ("detecting BlueZ version failed: %s", reason);
/* cancel current attempts to detect the version. */
cleanup_checking (self, FALSE);
diff --git a/src/devices/nm-device-logging.h b/src/devices/nm-device-logging.h
index 6255d6f381..8a2c9b681c 100644
--- a/src/devices/nm-device-logging.h
+++ b/src/devices/nm-device-logging.h
@@ -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__))
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index c062e88f81..4502cf5d3b 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -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),
diff --git a/src/dhcp-manager/nm-dhcp-client-logging.h b/src/dhcp-manager/nm-dhcp-client-logging.h
new file mode 100644
index 0000000000..4d289d8432
--- /dev/null
+++ b/src/dhcp-manager/nm-dhcp-client-logging.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager -- Network link manager
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2016 Red Hat, Inc.
+ */
+
+#ifndef __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__
+#define __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__
+
+#include "nm-default.h"
+#include "nm-dhcp-client.h"
+
+#define _NMLOG_PREFIX_NAME "dhcp"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ const NMLogLevel _level = (level); \
+ \
+ if (nm_logging_enabled (_level, LOGD_DHCP)) { \
+ NMDhcpClient *_self = (NMDhcpClient *) (self); \
+ const char *__ifname = _self ? nm_dhcp_client_get_iface (_self) : NULL; \
+ const NMLogDomain _domain = !_self \
+ ? LOGD_DHCP \
+ : (nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4); \
+ \
+ nm_log (_level, _domain, \
+ "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME, \
+ (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
+ NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \
+ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } \
+ } G_STMT_END
+
+#endif /* __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ */
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index 0aeb6118a5..10c69049e0 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -35,6 +35,8 @@
#include "nm-dhcp-utils.h"
#include "nm-platform.h"
+#include "nm-dhcp-client-logging.h"
+
typedef struct {
char * iface;
int ifindex;
@@ -204,7 +206,7 @@ state_to_string (NMDhcpState state)
}
static NMDhcpState
-reason_to_state (const char *iface, const char *reason)
+reason_to_state (NMDhcpClient *self, const char *iface, const char *reason)
{
if (g_ascii_strcasecmp (reason, "bound") == 0 ||
g_ascii_strcasecmp (reason, "bound6") == 0 ||
@@ -226,7 +228,7 @@ reason_to_state (const char *iface, const char *reason)
g_ascii_strcasecmp (reason, "abend") == 0)
return NM_DHCP_STATE_FAIL;
- nm_log_dbg (LOGD_DHCP, "(%s): unmapped DHCP state '%s'", iface, reason);
+ _LOGD ("unmapped DHCP state '%s'", reason);
return NM_DHCP_STATE_UNKNOWN;
}
@@ -319,13 +321,10 @@ nm_dhcp_client_set_state (NMDhcpClient *self,
event_id = g_strdup_printf ("%s|%s", iaid, start);
}
- nm_log_info (priv->ipv6 ? LOGD_DHCP6 : LOGD_DHCP4,
- "(%s): DHCPv%c state changed %s -> %s%s%s%s",
- priv->iface,
- priv->ipv6 ? '6' : '4',
- state_to_string (priv->state),
- state_to_string (new_state),
- NM_PRINT_FMT_QUOTED (event_id, ", event ID=\"", event_id, "\"", ""));
+ _LOGI ("state changed %s -> %s%s%s%s",
+ state_to_string (priv->state),
+ state_to_string (new_state),
+ NM_PRINT_FMT_QUOTED (event_id, ", event ID=\"", event_id, "\"", ""));
priv->state = new_state;
g_signal_emit (G_OBJECT (self),
@@ -343,10 +342,7 @@ transaction_timeout (gpointer user_data)
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
priv->timeout_id = 0;
- nm_log_warn (priv->ipv6 ? LOGD_DHCP6 : LOGD_DHCP4,
- "(%s): DHCPv%c request timed out.",
- priv->iface,
- priv->ipv6 ? '6' : '4');
+ _LOGW ("request timed out");
nm_dhcp_client_set_state (self, NM_DHCP_STATE_TIMEOUT, NULL, NULL);
return G_SOURCE_REMOVE;
}
@@ -357,29 +353,20 @@ daemon_watch_cb (GPid pid, gint status, gpointer user_data)
NMDhcpClient *self = NM_DHCP_CLIENT (user_data);
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
NMDhcpState new_state;
- guint64 log_domain;
- guint ip_ver;
g_return_if_fail (priv->watch_id);
priv->watch_id = 0;
- log_domain = priv->ipv6 ? LOGD_DHCP6 : LOGD_DHCP4;
- ip_ver = priv->ipv6 ? 6 : 4;
-
if (WIFEXITED (status))
- nm_log_info (log_domain, "(%s): DHCPv%d client pid %d exited with status %d",
- priv->iface, ip_ver, pid, WEXITSTATUS (status));
+ _LOGI ("client pid %d exited with status %d", pid, WEXITSTATUS (status));
else if (WIFSIGNALED (status))
- nm_log_info (log_domain, "(%s): DHCPv%d client pid %d killed by signal %d",
- priv->iface, ip_ver, pid, WTERMSIG (status));
+ _LOGI ("client pid %d killed by signal %d", pid, WTERMSIG (status));
else if (WIFSTOPPED(status))
- nm_log_info (log_domain, "(%s): DHCPv%d client pid %d stopped by signal %d",
- priv->iface, ip_ver, pid, WSTOPSIG (status));
+ _LOGI ("client pid %d stopped by signal %d", pid, WSTOPSIG (status));
else if (WIFCONTINUED (status))
- nm_log_info (log_domain, "(%s): DHCPv%d client pid %d resumed (by SIGCONT)",
- priv->iface, ip_ver, pid);
+ _LOGI ("client pid %d resumed (by SIGCONT)", pid);
else
- nm_log_warn (LOGD_DHCP, "DHCP client died abnormally");
+ _LOGW ("client died abnormally");
if (!WIFEXITED (status))
new_state = NM_DHCP_STATE_FAIL;
@@ -434,8 +421,7 @@ nm_dhcp_client_start_ip4 (NMDhcpClient *self,
g_return_val_if_fail (priv->ipv6 == FALSE, FALSE);
g_return_val_if_fail (priv->uuid != NULL, FALSE);
- nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv4 transaction (timeout in %d seconds)",
- priv->iface, priv->timeout);
+ _LOGI ("activation: beginning transaction (timeout in %d seconds)", priv->timeout);
nm_dhcp_client_set_client_id (self, dhcp_client_id ? nm_dhcp_utils_client_id_string_to_bytes (dhcp_client_id) : NULL);
@@ -506,7 +492,7 @@ generate_duid_from_machine_id (void)
}
if (!success) {
- nm_log_warn (LOGD_DHCP6, "Failed to read " SYSCONFDIR "/machine-id "
+ nm_log_warn (LOGD_DHCP6, "dhcp6: failed to read " SYSCONFDIR "/machine-id "
"or " LOCALSTATEDIR "/lib/dbus/machine-id to generate "
"DHCPv6 DUID; creating non-persistent random DUID.");
@@ -546,7 +532,7 @@ get_duid (NMDhcpClient *self)
if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) {
str = nm_dhcp_utils_duid_to_string (duid);
- nm_log_dbg (LOGD_DHCP6, "Generated DUID %s", str);
+ _LOGD ("generated DUID %s", str);
g_free (str);
}
}
@@ -583,9 +569,9 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
if (!priv->duid)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self);
- if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP)) {
+ if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) {
str = nm_dhcp_utils_duid_to_string (priv->duid);
- nm_log_dbg (LOGD_DHCP, "(%s): DHCPv6 DUID is '%s'", priv->iface, str);
+ _LOGD ("DUID is '%s'", str);
g_free (str);
}
@@ -594,8 +580,8 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
priv->info_only = info_only;
- nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv6 transaction (timeout in %d seconds)",
- priv->iface, priv->timeout);
+ _LOGI ("activation: beginning transaction (timeout in %d seconds)",
+ priv->timeout);
return NM_DHCP_CLIENT_GET_CLASS (self)->ip6_start (self,
dhcp_anycast_addr,
@@ -645,8 +631,10 @@ nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name)
}
}
- if (remove (pid_file) == -1)
- nm_log_dbg (LOGD_DHCP, "Could not remove dhcp pid file \"%s\": %d (%s)", pid_file, errno, g_strerror (errno));
+ if (remove (pid_file) == -1) {
+ nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %d (%s)",
+ pid_file, errno, g_strerror (errno));
+ }
g_free (proc_path);
g_free (pid_contents);
@@ -666,11 +654,10 @@ nm_dhcp_client_stop (NMDhcpClient *self, gboolean release)
/* Kill the DHCP client */
old_pid = priv->pid;
NM_DHCP_CLIENT_GET_CLASS (self)->stop (self, release, priv->duid);
- if (old_pid > 0) {
- nm_log_info (LOGD_DHCP, "(%s): canceled DHCP transaction, DHCP client pid %d",
- priv->iface, old_pid);
- } else
- nm_log_info (LOGD_DHCP, "(%s): canceled DHCP transaction", priv->iface);
+ if (old_pid > 0)
+ _LOGI ("canceled DHCP transaction, DHCP client pid %d", old_pid);
+ else
+ _LOGI ("canceled DHCP transaction");
g_assert (priv->pid == -1);
nm_dhcp_client_set_state (self, NM_DHCP_STATE_DONE, NULL, NULL);
@@ -710,7 +697,7 @@ bytearray_variant_to_string (GVariant *value, const char *key)
converted = str->str;
if (!g_utf8_validate (converted, -1, NULL))
- nm_log_warn (LOGD_DHCP, "DHCP option '%s' couldn't be converted to UTF-8", key);
+ nm_log_warn (LOGD_DHCP, "dhcp: option '%s' couldn't be converted to UTF-8", key);
g_string_free (str, FALSE);
return converted;
}
@@ -782,9 +769,9 @@ nm_dhcp_client_handle_event (gpointer unused,
return FALSE;
old_state = priv->state;
- new_state = reason_to_state (priv->iface, reason);
- nm_log_dbg (LOGD_DHCP, "(%s): DHCP reason '%s' -> state '%s'",
- iface, reason, state_to_string (new_state));
+ new_state = reason_to_state (self, priv->iface, reason);
+ _LOGD ("DHCP reason '%s' -> state '%s'",
+ reason, state_to_string (new_state));
if (new_state == NM_DHCP_STATE_BOUND) {
GVariantIter iter;
@@ -817,7 +804,7 @@ nm_dhcp_client_handle_event (gpointer unused,
/* Fail if no valid IP config was received */
if (ip_config == NULL) {
- nm_log_warn (LOGD_DHCP, "(%s): DHCP client bound but IP config not received", iface);
+ _LOGW ("client bound but IP config not received");
new_state = NM_DHCP_STATE_FAIL;
g_clear_pointer (&str_options, g_hash_table_unref);
}
diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c
index e5329ef33c..4b6d301b50 100644
--- a/src/dhcp-manager/nm-dhcp-dhclient.c
+++ b/src/dhcp-manager/nm-dhcp-dhclient.c
@@ -41,6 +41,7 @@
#include "nm-dhcp-manager.h"
#include "NetworkManagerUtils.h"
#include "nm-dhcp-listener.h"
+#include "nm-dhcp-client-logging.h"
G_DEFINE_TYPE (NMDhcpDhclient, nm_dhcp_dhclient, NM_TYPE_DHCP_CLIENT)
@@ -148,7 +149,8 @@ nm_dhcp_dhclient_get_lease_ip_configs (const char *iface,
}
static gboolean
-merge_dhclient_config (const char *iface,
+merge_dhclient_config (NMDhcpDhclient *self,
+ const char *iface,
const char *conf_file,
gboolean is_ip6,
GBytes *client_id,
@@ -169,8 +171,8 @@ merge_dhclient_config (const char *iface,
GError *read_error = NULL;
if (!g_file_get_contents (orig_path, &orig, NULL, &read_error)) {
- nm_log_warn (LOGD_DHCP, "(%s): error reading dhclient%s configuration %s: %s",
- iface, is_ip6 ? "6" : "", orig_path, read_error->message);
+ _LOGW ("error reading dhclient configuration %s: %s",
+ orig_path, read_error->message);
g_error_free (read_error);
}
}
@@ -185,7 +187,7 @@ merge_dhclient_config (const char *iface,
}
static char *
-find_existing_config (const char *iface, const char *uuid, gboolean ipv6)
+find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid, gboolean ipv6)
{
char *path;
@@ -195,20 +197,20 @@ find_existing_config (const char *iface, const char *uuid, gboolean ipv6)
*/
if (uuid) {
path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", uuid);
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
}
path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface);
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
path = g_strdup_printf (NMCONFDIR "/dhclient%s.conf", ipv6 ? "6" : "");
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
@@ -222,25 +224,25 @@ find_existing_config (const char *iface, const char *uuid, gboolean ipv6)
* (including Fedora) don't even provide a default configuration file.
*/
path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s-%s.conf", ipv6 ? "6" : "", iface);
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
path = g_strdup_printf (SYSCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface);
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s.conf", ipv6 ? "6" : "");
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
path = g_strdup_printf (SYSCONFDIR "/dhclient%s.conf", ipv6 ? "6" : "");
- nm_log_dbg (ipv6 ? LOGD_DHCP6 : LOGD_DHCP4, "(%s) looking for existing config %s", iface, path);
+ _LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
@@ -256,7 +258,8 @@ find_existing_config (const char *iface, const char *uuid, gboolean ipv6)
* config file along with the NM options.
*/
static char *
-create_dhclient_config (const char *iface,
+create_dhclient_config (NMDhcpDhclient *self,
+ const char *iface,
gboolean is_ip6,
const char *uuid,
GBytes *client_id,
@@ -272,26 +275,19 @@ create_dhclient_config (const char *iface,
g_return_val_if_fail (iface != NULL, NULL);
new = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s.conf", is_ip6 ? "6" : "", iface);
- nm_log_dbg (is_ip6 ? LOGD_DHCP6 : LOGD_DHCP4,
- "(%s): creating composite dhclient config %s",
- iface, new);
-
- orig = find_existing_config (iface, uuid, is_ip6);
- if (orig) {
- nm_log_dbg (is_ip6 ? LOGD_DHCP6 : LOGD_DHCP4,
- "(%s): merging existing dhclient config %s",
- iface, orig);
- } else {
- nm_log_dbg (is_ip6 ? LOGD_DHCP6 : LOGD_DHCP4,
- "(%s): no existing dhclient configuration to merge",
- iface);
- }
+ _LOGD ("creating composite dhclient config %s", new);
+
+ orig = find_existing_config (self, iface, uuid, is_ip6);
+ if (orig)
+ _LOGD ("merging existing dhclient config %s", orig);
+ else
+ _LOGD ("no existing dhclient configuration to merge");
error = NULL;
- success = merge_dhclient_config (iface, new, is_ip6, client_id, dhcp_anycast_addr, hostname, fqdn, orig, out_new_client_id, &error);
+ success = merge_dhclient_config (self, iface, new, is_ip6, client_id, dhcp_anycast_addr,
+ hostname, fqdn, orig, out_new_client_id, &error);
if (!success) {
- nm_log_warn (LOGD_DHCP, "(%s): error creating dhclient%s configuration: %s",
- iface, is_ip6 ? "6" : "", error->message);
+ _LOGW ("error creating dhclient configuration: %s", error->message);
g_error_free (error);
}
@@ -307,14 +303,14 @@ dhclient_start (NMDhcpClient *client,
gboolean release,
pid_t *out_pid)
{
- NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
+ NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
+ NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
GPtrArray *argv = NULL;
pid_t pid;
GError *error = NULL;
const char *iface, *uuid, *system_bus_address, *dhclient_path = NULL;
char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL;
gboolean ipv6, success;
- guint log_domain;
char *escaped, *preferred_leasefile_path = NULL;
g_return_val_if_fail (priv->pid_file == NULL, FALSE);
@@ -323,11 +319,9 @@ dhclient_start (NMDhcpClient *client,
uuid = nm_dhcp_client_get_uuid (client);
ipv6 = nm_dhcp_client_get_ipv6 (client);
- log_domain = ipv6 ? LOGD_DHCP6 : LOGD_DHCP4;
-
dhclient_path = nm_dhcp_dhclient_get_path ();
if (!dhclient_path) {
- nm_log_warn (log_domain, "dhclient could not be found");
+ _LOGW ("dhclient could not be found");
return FALSE;
}
@@ -362,9 +356,9 @@ dhclient_start (NMDhcpClient *client,
priv->lease_file = g_strdup (g_file_get_path (dst));
} else {
/* Failure; just use the existing leasefile */
- nm_log_warn (log_domain, "Failed to copy leasefile %s to %s: %s",
- g_file_get_path (src), g_file_get_path (dst),
- error->message);
+ _LOGW ("failed to copy leasefile %s to %s: %s",
+ g_file_get_path (src), g_file_get_path (dst),
+ error->message);
g_clear_error (&error);
}
g_object_unref (src);
@@ -378,9 +372,7 @@ dhclient_start (NMDhcpClient *client,
success = nm_dhcp_dhclient_save_duid (priv->lease_file, escaped, &error);
g_free (escaped);
if (!success) {
- nm_log_warn (log_domain, "(%s): failed to save DUID to %s: %s.",
- iface, priv->lease_file,
- error->message);
+ _LOGW ("failed to save DUID to %s: %s", priv->lease_file, error->message);
g_free (pid_file);
return FALSE;
}
@@ -436,19 +428,19 @@ dhclient_start (NMDhcpClient *client,
g_ptr_array_add (argv, NULL);
cmd_str = g_strjoinv (" ", (gchar **) argv->pdata);
- nm_log_dbg (log_domain, "running: %s", cmd_str);
+ _LOGD ("running: %s", cmd_str);
g_free (cmd_str);
if (g_spawn_async (NULL, (char **) argv->pdata, NULL,
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
nm_utils_setpgid, NULL, &pid, &error)) {
g_assert (pid > 0);
- nm_log_info (log_domain, "dhclient started with pid %d", pid);
+ _LOGI ("dhclient started with pid %d", pid);
if (release == FALSE)
nm_dhcp_client_watch_child (client, pid);
priv->pid_file = pid_file;
} else {
- nm_log_warn (log_domain, "dhclient failed to start: '%s'", error->message);
+ _LOGW ("dhclient failed to start: '%s'", error->message);
g_error_free (error);
g_free (pid_file);
}
@@ -464,7 +456,8 @@ dhclient_start (NMDhcpClient *client,
static gboolean
ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address)
{
- NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
+ NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
+ NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
GBytes *client_id;
gs_unref_bytes GBytes *new_client_id = NULL;
const char *iface, *uuid, *hostname, *fqdn;
@@ -476,14 +469,14 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
hostname = nm_dhcp_client_get_hostname (client);
fqdn = nm_dhcp_client_get_fqdn (client);
- priv->conf_file = create_dhclient_config (iface, FALSE, uuid, client_id, dhcp_anycast_addr,
+ priv->conf_file = create_dhclient_config (self, iface, FALSE, uuid, client_id, dhcp_anycast_addr,
hostname, fqdn, &new_client_id);
if (priv->conf_file) {
if (new_client_id)
nm_dhcp_client_set_client_id (client, new_client_id);
success = dhclient_start (client, NULL, NULL, FALSE, NULL);
} else
- nm_log_warn (LOGD_DHCP4, "(%s): error creating dhclient configuration file.", iface);
+ _LOGW ("error creating dhclient configuration file");
return success;
}
@@ -496,16 +489,17 @@ ip6_start (NMDhcpClient *client,
NMSettingIP6ConfigPrivacy privacy,
const GByteArray *duid)
{
- NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
+ NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
+ NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
const char *iface, *uuid, *hostname;
iface = nm_dhcp_client_get_iface (client);
uuid = nm_dhcp_client_get_uuid (client);
hostname = nm_dhcp_client_get_hostname (client);
- priv->conf_file = create_dhclient_config (iface, TRUE, uuid, NULL, dhcp_anycast_addr, hostname, NULL, NULL);
+ priv->conf_file = create_dhclient_config (self, iface, TRUE, uuid, NULL, dhcp_anycast_addr, hostname, NULL, NULL);
if (!priv->conf_file) {
- nm_log_warn (LOGD_DHCP6, "(%s): error creating dhclient6 configuration file.", iface);
+ _LOGW ("error creating dhclient configuration file");
return FALSE;
}
@@ -515,17 +509,18 @@ ip6_start (NMDhcpClient *client,
static void
stop (NMDhcpClient *client, gboolean release, const GByteArray *duid)
{
- NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
+ NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
+ NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
/* Chain up to parent */
NM_DHCP_CLIENT_CLASS (nm_dhcp_dhclient_parent_class)->stop (client, release, duid);
if (priv->conf_file)
if (remove (priv->conf_file) == -1)
- nm_log_dbg (LOGD_DHCP, "Could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errno, g_strerror (errno));
+ _LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errno, g_strerror (errno));
if (priv->pid_file) {
if (remove (priv->pid_file) == -1)
- nm_log_dbg (LOGD_DHCP, "Could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno));
+ _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno));
g_free (priv->pid_file);
priv->pid_file = NULL;
}
@@ -561,7 +556,8 @@ state_changed (NMDhcpClient *client,
static GByteArray *
get_duid (NMDhcpClient *client)
{
- NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
+ NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
+ NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
GByteArray *duid = NULL;
char *leasefile;
GError *error = NULL;
@@ -572,12 +568,12 @@ get_duid (NMDhcpClient *client)
TRUE,
NULL);
if (leasefile) {
- nm_log_dbg (LOGD_DHCP, "Looking for DHCPv6 DUID in '%s'.", leasefile);
+ _LOGD ("looking for DUID in '%s'", leasefile);
duid = nm_dhcp_dhclient_read_duid (leasefile, &error);
if (error) {
- nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': %s",
- leasefile, error->message);
+ _LOGW ("failed to read leasefile '%s': %s",
+ leasefile, error->message);
g_clear_error (&error);
}
g_free (leasefile);
@@ -585,12 +581,12 @@ get_duid (NMDhcpClient *client)
if (!duid && priv->def_leasefile) {
/* Otherwise read the default machine-wide DUID */
- nm_log_dbg (LOGD_DHCP, "Looking for default DHCPv6 DUID in '%s'.", priv->def_leasefile);
+ _LOGD ("looking for default DUID in '%s'", priv->def_leasefile);
duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &error);
if (error) {
- nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': %s",
- priv->def_leasefile,
- error->message);
+ _LOGW ("failed to read leasefile '%s': %s",
+ priv->def_leasefile,
+ error->message);
g_clear_error (&error);
}
}
diff --git a/src/dhcp-manager/nm-dhcp-dhcpcd.c b/src/dhcp-manager/nm-dhcp-dhcpcd.c
index 8060cc6a75..8bbb6e4c71 100644
--- a/src/dhcp-manager/nm-dhcp-dhcpcd.c
+++ b/src/dhcp-manager/nm-dhcp-dhcpcd.c
@@ -36,6 +36,7 @@
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-dhcp-listener.h"
+#include "nm-dhcp-client-logging.h"
G_DEFINE_TYPE (NMDhcpDhcpcd, nm_dhcp_dhcpcd, NM_TYPE_DHCP_CLIENT)
@@ -58,7 +59,8 @@ nm_dhcp_dhcpcd_get_path (void)
static gboolean
ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address)
{
- NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (client);
+ NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client);
+ NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self);
GPtrArray *argv = NULL;
pid_t pid = -1;
GError *error = NULL;
@@ -77,7 +79,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
dhcpcd_path = nm_dhcp_dhcpcd_get_path ();
if (!dhcpcd_path) {
- nm_log_warn (LOGD_DHCP4, "dhcpcd could not be found");
+ _LOGW ("dhcpcd could not be found");
return FALSE;
}
@@ -134,17 +136,17 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
g_ptr_array_add (argv, NULL);
cmd_str = g_strjoinv (" ", (gchar **) argv->pdata);
- nm_log_dbg (LOGD_DHCP4, "running: %s", cmd_str);
+ _LOGD ("running: %s", cmd_str);
g_free (cmd_str);
if (g_spawn_async (NULL, (char **) argv->pdata, NULL,
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
nm_utils_setpgid, NULL, &pid, &error)) {
g_assert (pid > 0);
- nm_log_info (LOGD_DHCP4, "dhcpcd started with pid %d", pid);
+ _LOGI ("dhcpcd started with pid %d", pid);
nm_dhcp_client_watch_child (client, pid);
} else {
- nm_log_warn (LOGD_DHCP4, "dhcpcd failed to start. error: '%s'", error->message);
+ _LOGW ("dhcpcd failed to start, error: '%s'", error->message);
g_error_free (error);
}
@@ -161,21 +163,24 @@ ip6_start (NMDhcpClient *client,
NMSettingIP6ConfigPrivacy privacy,
const GByteArray *duid)
{
- nm_log_warn (LOGD_DHCP6, "the dhcpcd backend does not support IPv6.");
+ NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client);
+
+ _LOGW ("the dhcpcd backend does not support IPv6");
return FALSE;
}
static void
stop (NMDhcpClient *client, gboolean release, const GByteArray *duid)
{
- NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (client);
+ NMDhcpDhcpcd *self = NM_DHCP_DHCPCD (client);
+ NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (self);
/* Chain up to parent */
NM_DHCP_CLIENT_CLASS (nm_dhcp_dhcpcd_parent_class)->stop (client, release, duid);
if (priv->pid_file) {
if (remove (priv->pid_file) == -1)
- nm_log_dbg (LOGD_DHCP, "Could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno));
+ _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno));
}
/* FIXME: implement release... */
diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c
index 7bb69819c2..7b3575ec14 100644
--- a/src/dhcp-manager/nm-dhcp-systemd.c
+++ b/src/dhcp-manager/nm-dhcp-systemd.c
@@ -33,6 +33,7 @@
#include "nm-dhcp-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-platform.h"
+#include "nm-dhcp-client-logging.h"
#include "sd-dhcp-client.h"
#include "sd-dhcp6-client.h"
@@ -465,15 +466,15 @@ bound4_handle (NMDhcpSystemd *self)
GError *error = NULL;
int r;
- nm_log_dbg (LOGD_DHCP4, "(%s): lease available", iface);
-
r = sd_dhcp_client_get_lease (priv->client4, &lease);
if (r < 0 || !lease) {
- nm_log_warn (LOGD_DHCP4, "(%s): no lease!", iface);
+ _LOGW ("no lease!");
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
return;
}
+ _LOGD ("lease available");
+
options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
ip4_config = lease_to_ip4_config (iface,
nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)),
@@ -499,7 +500,7 @@ bound4_handle (NMDhcpSystemd *self)
G_OBJECT (ip4_config),
options);
} else {
- nm_log_warn (LOGD_DHCP4, "(%s): %s", iface, error->message);
+ _LOGW ("%s", error->message);
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
g_clear_error (&error);
}
@@ -513,11 +514,10 @@ dhcp_event_cb (sd_dhcp_client *client, int event, gpointer user_data)
{
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data);
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
- const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self));
g_assert (priv->client4 == client);
- nm_log_dbg (LOGD_DHCP4, "(%s): DHCPv4 client event %d", iface, event);
+ _LOGD ("client event %d", event);
switch (event) {
case SD_DHCP_CLIENT_EVENT_EXPIRED:
@@ -532,7 +532,7 @@ dhcp_event_cb (sd_dhcp_client *client, int event, gpointer user_data)
bound4_handle (self);
break;
default:
- nm_log_warn (LOGD_DHCP4, "(%s): unhandled DHCP event %d", iface, event);
+ _LOGW ("unhandled DHCP event %d", event);
break;
}
}
@@ -551,7 +551,8 @@ get_arp_type (const GByteArray *hwaddr)
static gboolean
ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last_ip4_address)
{
- NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (client);
+ NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
+ NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
const char *iface = nm_dhcp_client_get_iface (client);
const GByteArray *hwaddr;
sd_dhcp_lease *lease = NULL;
@@ -572,13 +573,13 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
r = sd_dhcp_client_new (&priv->client4);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to create DHCPv4 client (%d)", iface, r);
+ _LOGW ("failed to create client (%d)", r);
return FALSE;
}
r = sd_dhcp_client_attach_event (priv->client4, NULL, 0);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to attach DHCP event (%d)", iface, r);
+ _LOGW ("failed to attach event (%d)", r);
goto error;
}
@@ -586,7 +587,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
if (hwaddr) {
arp_type= get_arp_type (hwaddr);
if (arp_type == ARPHRD_NONE) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to determine ARP type", iface);
+ _LOGW ("failed to determine ARP type");
goto error;
}
@@ -595,26 +596,26 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
hwaddr->len,
arp_type);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP MAC address (%d)", iface, r);
+ _LOGW ("failed to set MAC address (%d)", r);
goto error;
}
}
r = sd_dhcp_client_set_index (priv->client4, nm_dhcp_client_get_ifindex (client));
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP ifindex (%d)", iface, r);
+ _LOGW ("failed to set ifindex (%d)", r);
goto error;
}
r = sd_dhcp_client_set_callback (priv->client4, dhcp_event_cb, client);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP callback (%d)", iface, r);
+ _LOGW ("failed to set callback (%d)", r);
goto error;
}
r = sd_dhcp_client_set_request_broadcast (priv->client4, true);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP broadcast (%d)", iface, r);
+ _LOGW ("failed to enable broadcast mode (%d)", r);
goto error;
}
@@ -628,7 +629,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
if (last_addr.s_addr) {
r = sd_dhcp_client_set_request_address (priv->client4, &last_addr);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set last IPv4 address (%d)", iface, r);
+ _LOGW ("failed to set last IPv4 address (%d)", r);
goto error;
}
}
@@ -676,7 +677,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
free (prefix);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP hostname (%d)", iface, r);
+ _LOGW ("failed to set DHCP hostname (%d)", r);
goto error;
}
}
@@ -685,14 +686,14 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
if (fqdn) {
r = sd_dhcp_client_set_hostname (priv->client4, fqdn);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to set DHCP FQDN (%d)", iface, r);
+ _LOGW ("failed to set DHCP FQDN (%d)", r);
goto error;
}
}
r = sd_dhcp_client_start (priv->client4);
if (r < 0) {
- nm_log_warn (LOGD_DHCP4, "(%s): failed to start DHCP (%d)", iface, r);
+ _LOGW ("failed to start client (%d)", r);
goto error;
}
@@ -810,12 +811,12 @@ bound6_handle (NMDhcpSystemd *self)
r = sd_dhcp6_client_get_lease (priv->client6, &lease);
if (r < 0 || !lease) {
- nm_log_warn (LOGD_DHCP6, "(%s): no lease!", iface);
+ _LOGW (" no lease!");
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
return;
}
- nm_log_dbg (LOGD_DHCP6, "(%s): lease available", iface);
+ _LOGD ("lease available");
options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
ip6_config = lease_to_ip6_config (iface,
@@ -832,7 +833,7 @@ bound6_handle (NMDhcpSystemd *self)
G_OBJECT (ip6_config),
options);
} else {
- nm_log_warn (LOGD_DHCP6, "(%s): %s", iface, error->message);
+ _LOGW ("%s", error->message);
nm_dhcp_client_set_state (NM_DHCP_CLIENT (self), NM_DHCP_STATE_FAIL, NULL, NULL);
}
}
@@ -842,11 +843,10 @@ dhcp6_event_cb (sd_dhcp6_client *client, int event, gpointer user_data)
{
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (user_data);
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
- const char *iface = nm_dhcp_client_get_iface (NM_DHCP_CLIENT (self));
g_assert (priv->client6 == client);
- nm_log_dbg (LOGD_DHCP6, "(%s): DHCPv6 client event %d", iface, event);
+ _LOGD ("client event %d", event);
switch (event) {
case SD_DHCP6_CLIENT_EVENT_RETRANS_MAX:
@@ -860,7 +860,7 @@ dhcp6_event_cb (sd_dhcp6_client *client, int event, gpointer user_data)
bound6_handle (self);
break;
default:
- nm_log_warn (LOGD_DHCP6, "(%s): unhandled DHCPv6 event %d", iface, event);
+ _LOGW ("unhandled event %d", event);
break;
}
}
@@ -873,7 +873,8 @@ ip6_start (NMDhcpClient *client,
NMSettingIP6ConfigPrivacy privacy,
const GByteArray *duid)
{
- NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (client);
+ NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
+ NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
const char *iface = nm_dhcp_client_get_iface (client);
const GByteArray *hwaddr;
int r, i;
@@ -888,7 +889,7 @@ ip6_start (NMDhcpClient *client,
r = sd_dhcp6_client_new (&priv->client6);
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to create DHCPv6 client (%d)", iface, r);
+ _LOGW ("failed to create client (%d)", r);
return FALSE;
}
@@ -900,13 +901,13 @@ ip6_start (NMDhcpClient *client,
duid->data + 2,
duid->len - 2);
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to create DHCPv6 client (%d)", iface, r);
+ _LOGW ("failed to set DUID (%d)", r);
return FALSE;
}
r = sd_dhcp6_client_attach_event (priv->client6, NULL, 0);
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to attach DHCP event (%d)", iface, r);
+ _LOGW ("failed to attach event (%d)", r);
goto error;
}
@@ -917,20 +918,20 @@ ip6_start (NMDhcpClient *client,
hwaddr->len,
get_arp_type (hwaddr));
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to set DHCP MAC address (%d)", iface, r);
+ _LOGW ("failed to set MAC address (%d)", r);
goto error;
}
}
r = sd_dhcp6_client_set_index (priv->client6, nm_dhcp_client_get_ifindex (client));
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to set DHCP ifindex (%d)", iface, r);
+ _LOGW ("failed to set ifindex (%d)", r);
goto error;
}
r = sd_dhcp6_client_set_callback (priv->client6, dhcp6_event_cb, client);
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to set DHCP callback (%d)", iface, r);
+ _LOGW ("failed to set callback (%d)", r);
goto error;
}
@@ -942,13 +943,13 @@ ip6_start (NMDhcpClient *client,
r = sd_dhcp6_client_set_local_address (priv->client6, ll_addr);
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to set local address (%d)", iface, r);
+ _LOGW ("failed to set local address (%d)", r);
goto error;
}
r = sd_dhcp6_client_start (priv->client6);
if (r < 0) {
- nm_log_warn (LOGD_DHCP6, "(%s): failed to start DHCP (%d)", iface, r);
+ _LOGW ("failed to start client (%d)", r);
goto error;
}
@@ -963,7 +964,8 @@ error:
static void
stop (NMDhcpClient *client, gboolean release, const GByteArray *duid)
{
- NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (client);
+ NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
+ NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
int r = 0;
if (priv->client4) {
@@ -974,12 +976,8 @@ stop (NMDhcpClient *client, gboolean release, const GByteArray *duid)
r = sd_dhcp6_client_stop (priv->client6);
}
- if (r) {
- nm_log_warn (priv->client6 ? LOGD_DHCP6 : LOGD_DHCP4,
- "(%s): failed to stop DHCP client (%d)",
- nm_dhcp_client_get_iface (client),
- r);
- }
+ if (r)
+ _LOGW ("failed to stop client (%d)", r);
}
/***************************************************/
diff --git a/src/dnsmasq-manager/nm-dnsmasq-manager.c b/src/dnsmasq-manager/nm-dnsmasq-manager.c
index 9e388acfb9..31c1db247e 100644
--- a/src/dnsmasq-manager/nm-dnsmasq-manager.c
+++ b/src/dnsmasq-manager/nm-dnsmasq-manager.c
@@ -34,6 +34,16 @@
#include "NetworkManagerUtils.h"
#include "nm-core-internal.h"
+#define _NMLOG_DOMAIN LOGD_SHARING
+#define _NMLOG_PREFIX_NAME "dnsmasq-manager"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
typedef struct {
char *iface;
char *pidfile;
@@ -181,7 +191,7 @@ dm_exit_code (guint dm_exit_status)
break;
}
- nm_log_warn (LOGD_SHARING, "dnsmasq exited with error: %s (%d)", msg, dm_exit_status);
+ _LOGW ("dnsmasq exited with error: %s (%d)", msg, dm_exit_status);
}
static void
@@ -196,11 +206,11 @@ dm_watch_cb (GPid pid, gint status, gpointer user_data)
if (err != 0)
dm_exit_code (err);
} else if (WIFSTOPPED (status)) {
- nm_log_warn (LOGD_SHARING, "dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status));
+ _LOGW ("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG (status));
} else if (WIFSIGNALED (status)) {
- nm_log_warn (LOGD_SHARING, "dnsmasq died with signal %d", WTERMSIG (status));
+ _LOGW ("dnsmasq died with signal %d", WTERMSIG (status));
} else {
- nm_log_warn (LOGD_SHARING, "dnsmasq died from an unknown cause");
+ _LOGW ("dnsmasq died from an unknown cause");
}
priv->pid = 0;
@@ -269,7 +279,7 @@ create_dm_cmd_line (const char *iface,
NM_MANAGER_ERROR,
NM_MANAGER_ERROR_FAILED,
error_desc);
- nm_log_warn (LOGD_SHARING, "Failed to find DHCP address ranges: %s", error_desc);
+ _LOGW ("failed to find DHCP address ranges: %s", error_desc);
g_free (error_desc);
nm_cmd_line_destroy (cmd);
return NULL;
@@ -361,10 +371,8 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager,
g_ptr_array_add (dm_cmd->array, NULL);
- nm_log_info (LOGD_SHARING, "Starting dnsmasq...");
-
- nm_log_dbg (LOGD_SHARING, "Command line: %s",
- (cmd_str = nm_cmd_line_to_str (dm_cmd)));
+ _LOGI ("starting dnsmasq...");
+ _LOGD ("command line: %s", (cmd_str = nm_cmd_line_to_str (dm_cmd)));
priv->pid = 0;
if (!g_spawn_async (NULL, (char **) dm_cmd->array->pdata, NULL,
@@ -374,7 +382,7 @@ nm_dnsmasq_manager_start (NMDnsMasqManager *manager,
goto out;
}
- nm_log_dbg (LOGD_SHARING, "dnsmasq started with pid %d", priv->pid);
+ _LOGD ("dnsmasq started with pid %d", priv->pid);
priv->dm_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) dm_watch_cb, manager);
diff --git a/src/nm-audit-manager.c b/src/nm-audit-manager.c
index b4cfb20b60..728575f663 100644
--- a/src/nm-audit-manager.c
+++ b/src/nm-audit-manager.c
@@ -34,6 +34,15 @@
#define AUDIT_LOG_LEVEL LOGL_INFO
+#define _NMLOG_PREFIX_NAME "audit"
+#define _NMLOG(level, domain, ...) \
+ G_STMT_START { \
+ nm_log ((level), (domain), \
+ "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } G_STMT_END
+
typedef enum {
BACKEND_LOG = (1 << 0),
BACKEND_AUDITD = (1 << 1),
@@ -154,7 +163,7 @@ nm_audit_log (NMAuditManager *self, GPtrArray *fields, const char *file,
if (nm_logging_enabled (AUDIT_LOG_LEVEL, LOGD_AUDIT)) {
msg = build_message (fields, BACKEND_LOG);
- _nm_log_impl (file, line, func, AUDIT_LOG_LEVEL, LOGD_AUDIT, 0, "%s", msg);
+ _NMLOG (AUDIT_LOG_LEVEL, LOGD_AUDIT, "%s", msg);
g_free (msg);
}
}
@@ -306,17 +315,16 @@ init_auditd (NMAuditManager *self)
NM_CONFIG_DEFAULT_LOGGING_AUDIT)) {
if (priv->auditd_fd < 0) {
priv->auditd_fd = audit_open ();
- if (priv->auditd_fd < 0) {
- nm_log_err (LOGD_CORE, "failed to open auditd socket: %s",
- strerror (errno));
- } else
- nm_log_dbg (LOGD_CORE, "audit socket created");
+ if (priv->auditd_fd < 0)
+ _LOGE (LOGD_CORE, "failed to open auditd socket: %s", strerror (errno));
+ else
+ _LOGD (LOGD_CORE, "socket created");
}
} else {
if (priv->auditd_fd >= 0) {
audit_close (priv->auditd_fd);
priv->auditd_fd = -1;
- nm_log_dbg (LOGD_CORE, "audit socket closed");
+ _LOGD (LOGD_CORE, "socket closed");
}
}
}
diff --git a/src/nm-bus-manager.c b/src/nm-bus-manager.c
index b6245b246b..2e55177cfe 100644
--- a/src/nm-bus-manager.c
+++ b/src/nm-bus-manager.c
@@ -34,6 +34,16 @@
#include "nm-exported-object.h"
#include "NetworkManagerUtils.h"
+#define _NMLOG_DOMAIN LOGD_CORE
+#define _NMLOG_PREFIX_NAME "bus-manager"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
enum {
DBUS_CONNECTION_CHANGED = 0,
PRIVATE_CONNECTION_NEW,
@@ -100,7 +110,7 @@ nm_bus_manager_setup (NMBusManager *instance)
already_setup = TRUE;
singleton_instance = instance;
nm_singleton_instance_register ();
- nm_log_dbg (LOGD_CORE, "setup %s singleton (%p)", "NMBusManager", singleton_instance);
+ _LOGD ("setup %s singleton (%p)", "NMBusManager", singleton_instance);
}
/**************************************************************/
@@ -176,8 +186,7 @@ private_server_closed_connection (GDBusConnection *conn,
CloseConnectionInfo *info;
/* Clean up after the connection */
- nm_log_dbg (LOGD_CORE, "(%s) closed connection %p on private socket.",
- s->tag, conn);
+ _LOGD ("(%s) closed connection %p on private socket", s->tag, conn);
info = g_slice_new0 (CloseConnectionInfo);
info->connection = conn;
@@ -210,8 +219,7 @@ private_server_new_connection (GDBusServer *server,
g_dbus_object_manager_server_set_connection (manager, conn);
g_hash_table_insert (s->obj_managers, manager, sender);
- nm_log_dbg (LOGD_CORE, "(%s) accepted connection %p on private socket.",
- s->tag, conn);
+ _LOGD ("(%s) accepted connection %p on private socket", s->tag, conn);
/* Emit this for the manager */
g_signal_emit (s->manager,
@@ -256,7 +264,7 @@ private_server_new (const char *path,
unlink (path);
address = g_strdup_printf ("unix:path=%s", path);
- nm_log_dbg (LOGD_CORE, "(%s) creating private socket %s.", tag, address);
+ _LOGD ("(%s) creating private socket %s", tag, address);
guid = g_dbus_generate_guid ();
auth_observer = g_dbus_auth_observer_new ();
@@ -271,8 +279,8 @@ private_server_new (const char *path,
g_object_unref (auth_observer);
if (!server) {
- nm_log_warn (LOGD_CORE, "(%s) failed to set up private socket %s: %s",
- tag, address, error->message);
+ _LOGW ("(%s) failed to set up private socket %s: %s",
+ tag, address, error->message);
g_error_free (error);
g_free (address);
return NULL;
@@ -547,8 +555,8 @@ nm_bus_manager_get_unix_user (NMBusManager *self,
/* Otherwise, a bus connection */
if (!_bus_get_unix_user (self, sender, out_uid, &error)) {
- nm_log_warn (LOGD_CORE, "Failed to get unix user for dbus sender '%s': %s",
- sender, error->message);
+ _LOGW ("failed to get unix user for dbus sender '%s': %s",
+ sender, error->message);
g_error_free (error);
return FALSE;
}
@@ -661,7 +669,7 @@ nm_bus_manager_reconnect (gpointer user_data)
if (nm_bus_manager_init_bus (self)) {
if (nm_bus_manager_start_service (self)) {
- nm_log_info (LOGD_CORE, "reconnected to the system bus.");
+ _LOGI ("reconnected to the system bus");
g_signal_emit (self, signals[DBUS_CONNECTION_CHANGED],
0, priv->connection);
priv->reconnect_id = 0;
@@ -695,7 +703,7 @@ closed_cb (GDBusConnection *connection,
NMBusManager *self = NM_BUS_MANAGER (user_data);
/* Clean up existing connection */
- nm_log_warn (LOGD_CORE, "disconnected by the system bus.");
+ _LOGW ("disconnected by the system bus");
nm_bus_manager_cleanup (self);
@@ -711,7 +719,7 @@ nm_bus_manager_init_bus (NMBusManager *self)
GError *error = NULL;
if (priv->connection) {
- nm_log_warn (LOGD_CORE, "DBus Manager already has a valid connection.");
+ _LOGW ("DBus Manager already has a valid connection");
return FALSE;
}
@@ -721,9 +729,9 @@ nm_bus_manager_init_bus (NMBusManager *self)
* environments (eg, initrd) where we only want to use the private
* socket.
*/
- nm_log_info (LOGD_CORE, "Could not connect to the system bus (%s); only the "
- "private D-Bus socket will be available.",
- error->message);
+ _LOGI ("could not connect to the system bus (%s); only the "
+ "private D-Bus socket will be available",
+ error->message);
g_error_free (error);
return FALSE;
}
@@ -742,9 +750,9 @@ nm_bus_manager_init_bus (NMBusManager *self)
NULL, &error);
if (!priv->proxy) {
g_clear_object (&priv->connection);
- nm_log_warn (LOGD_CORE, "Could not create org.freedesktop.DBus proxy (%s); only the "
- "private D-Bus socket will be available.",
- error->message);
+ _LOGW ("could not create org.freedesktop.DBus proxy (%s); only the "
+ "private D-Bus socket will be available",
+ error->message);
g_error_free (error);
return FALSE;
}
@@ -770,7 +778,7 @@ nm_bus_manager_start_service (NMBusManager *self)
priv = NM_BUS_MANAGER_GET_PRIVATE (self);
if (priv->started) {
- nm_log_err (LOGD_CORE, "Service has already started.");
+ _LOGE ("service has already started");
return FALSE;
}
@@ -787,8 +795,7 @@ nm_bus_manager_start_service (NMBusManager *self)
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &err);
if (!ret) {
- nm_log_err (LOGD_CORE, "Could not acquire the NetworkManager service.\n"
- " Error: '%s'", err->message);
+ _LOGE ("could not acquire the NetworkManager service: '%s'", err->message);
g_error_free (err);
return FALSE;
}
@@ -796,7 +803,7 @@ nm_bus_manager_start_service (NMBusManager *self)
g_variant_get (ret, "(u)", &result);
if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- nm_log_err (LOGD_CORE, "Could not acquire the NetworkManager service as it is already taken.");
+ _LOGE ("could not acquire the NetworkManager service as it is already taken");
return FALSE;
}
@@ -940,8 +947,8 @@ nm_bus_manager_new_proxy (NMBusManager *self,
"g-interface-name", iface,
NULL);
if (!proxy) {
- nm_log_warn (LOGD_CORE, "Could not create proxy for %s on connection %s: %s",
- iface, name, error->message);
+ _LOGW ("could not create proxy for %s on connection %s: %s",
+ iface, name, error->message);
g_error_free (error);
}
return proxy;
diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c
index c0238fc59a..4959ed5d14 100644
--- a/src/nm-dispatcher.c
+++ b/src/nm-dispatcher.c
@@ -39,6 +39,16 @@
#define CALL_TIMEOUT (1000 * 60 * 10) /* 10 minutes for all scripts */
+#define _NMLOG_DOMAIN LOGD_DISPATCH
+#define _NMLOG_PREFIX_NAME "dispatcher"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
static GDBusProxy *dispatcher_proxy;
static GHashTable *requests = NULL;
@@ -332,8 +342,7 @@ dispatcher_results_process (guint request_id, DispatcherAction action, GVariantI
g_return_if_fail (results != NULL);
if (g_variant_iter_n_children (results) == 0) {
- nm_log_dbg (LOGD_DISPATCH, "(%u) succeeded but no scripts invoked",
- request_id);
+ _LOGD ("(%u) succeeded but no scripts invoked", request_id);
return;
}
@@ -353,15 +362,16 @@ dispatcher_results_process (guint request_id, DispatcherAction action, GVariantI
script_validation_msg = " (unexpected path)";
if (result == DISPATCH_RESULT_SUCCESS) {
- nm_log_dbg (LOGD_DISPATCH, "(%u) %s succeeded%s",
- request_id,
- script, script_validation_msg);
+ _LOGD ("(%u) %s succeeded%s",
+ request_id,
+ script, script_validation_msg);
} else {
- nm_log_warn (LOGD_DISPATCH, "(%u) %s failed (%s): %s%s",
- request_id,
- script,
- dispatch_result_to_string (result),
- err, script_validation_msg);
+ _LOGW ("(%u) %s failed (%s): %s%s",
+ request_id,
+ script,
+ dispatch_result_to_string (result),
+ err,
+ script_validation_msg);
}
}
}
@@ -385,11 +395,11 @@ dispatcher_done_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
} else {
if (_nm_dbus_error_has_name (error, "org.freedesktop.systemd1.LoadFailed")) {
g_dbus_error_strip_remote_error (error);
- nm_log_warn (LOGD_DISPATCH, "(%u) failed to call dispatcher scripts: %s",
- info->request_id, error->message);
+ _LOGW ("(%u) failed to call dispatcher scripts: %s",
+ info->request_id, error->message);
} else {
- nm_log_dbg (LOGD_DISPATCH, "(%u) failed to call dispatcher scripts: %s",
- info->request_id, error->message);
+ _LOGD ("(%u) failed to call dispatcher scripts: %s",
+ info->request_id, error->message);
}
g_clear_error (&error);
}
@@ -474,21 +484,21 @@ _dispatcher_call (DispatcherAction action,
/* All actions except 'hostname' require a device */
if (action == DISPATCHER_ACTION_HOSTNAME) {
- nm_log_dbg (LOGD_DISPATCH, "(%u) dispatching action '%s'%s",
- reqid, action_to_string (action),
- blocking
- ? " (blocking)"
- : (callback ? " (with callback)" : ""));
+ _LOGD ("(%u) dispatching action '%s'%s",
+ reqid, action_to_string (action),
+ blocking
+ ? " (blocking)"
+ : (callback ? " (with callback)" : ""));
} else {
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
- nm_log_dbg (LOGD_DISPATCH, "(%u) (%s) dispatching action '%s'%s",
- reqid,
- vpn_iface ? vpn_iface : nm_device_get_iface (device),
- action_to_string (action),
- blocking
- ? " (blocking)"
- : (callback ? " (with callback)" : ""));
+ _LOGD ("(%u) (%s) dispatching action '%s'%s",
+ reqid,
+ vpn_iface ? vpn_iface : nm_device_get_iface (device),
+ action_to_string (action),
+ blocking
+ ? " (blocking)"
+ : (callback ? " (with callback)" : ""));
}
if (!_get_monitor_by_action(action)->has_scripts) {
@@ -499,9 +509,9 @@ _dispatcher_call (DispatcherAction action,
info->callback = callback;
info->user_data = user_data;
info->idle_id = g_idle_add (dispatcher_idle_cb, info);
- nm_log_dbg (LOGD_DISPATCH, "(%u) simulate request; no scripts in %s", reqid, _get_monitor_by_action(action)->dir);
+ _LOGD ("(%u) simulate request; no scripts in %s", reqid, _get_monitor_by_action(action)->dir);
} else
- nm_log_dbg (LOGD_DISPATCH, "(%u) ignoring request; no scripts in %s", reqid, _get_monitor_by_action(action)->dir);
+ _LOGD ("(%u) ignoring request; no scripts in %s", reqid, _get_monitor_by_action(action)->dir);
success = TRUE;
goto done;
}
@@ -592,7 +602,7 @@ _dispatcher_call (DispatcherAction action,
success = TRUE;
} else {
g_dbus_error_strip_remote_error (error);
- nm_log_warn (LOGD_DISPATCH, "(%u) failed: %s", reqid, error->message);
+ _LOGW ("(%u) failed: %s", reqid, error->message);
g_clear_error (&error);
success = FALSE;
}
@@ -764,8 +774,7 @@ nm_dispatcher_call_cancel (guint call_id)
g_return_if_fail (info);
if (info && info->callback) {
- nm_log_dbg (LOGD_DISPATCH, "(%u) cancelling dispatcher callback action",
- call_id);
+ _LOGD ("(%u) cancelling dispatcher callback action", call_id);
info->callback = NULL;
}
}
@@ -797,19 +806,19 @@ dispatcher_dir_changed (GFileMonitor *monitor,
errsv = errno;
g_dir_close (dir);
if (item->has_scripts)
- nm_log_dbg (LOGD_DISPATCH, "dispatcher: %s script directory '%s' has scripts", item->description, item->dir);
+ _LOGD ("%s script directory '%s' has scripts", item->description, item->dir);
else if (errsv == 0)
- nm_log_dbg (LOGD_DISPATCH, "dispatcher: %s script directory '%s' has no scripts", item->description, item->dir);
+ _LOGD ("%s script directory '%s' has no scripts", item->description, item->dir);
else {
- nm_log_dbg (LOGD_DISPATCH, "dispatcher: %s script directory '%s' error reading (%s)", item->description, item->dir, strerror (errsv));
+ _LOGD ("%s script directory '%s' error reading (%s)", item->description, item->dir, strerror (errsv));
item->has_scripts = TRUE;
}
} else {
if (g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
- nm_log_dbg (LOGD_DISPATCH, "dispatcher: %s script directory '%s' does not exist", item->description, item->dir);
+ _LOGD ("%s script directory '%s' does not exist", item->description, item->dir);
item->has_scripts = FALSE;
} else {
- nm_log_dbg (LOGD_DISPATCH, "dispatcher: %s script directory '%s' error (%s)", item->description, item->dir, error->message);
+ _LOGD ("%s script directory '%s' error (%s)", item->description, item->dir, error->message);
item->has_scripts = TRUE;
}
g_error_free (error);
@@ -843,7 +852,7 @@ nm_dispatcher_init (void)
NM_DISPATCHER_DBUS_INTERFACE,
NULL, &error);
if (!dispatcher_proxy) {
- nm_log_err (LOGD_DISPATCH, "could not get dispatcher proxy! %s", error->message);
+ _LOGE ("could not get dispatcher proxy! %s", error->message);
g_clear_error (&error);
}
}
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 97102770c5..41b5c16007 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -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,
diff --git a/src/nm-policy.c b/src/nm-policy.c
index b54468167c..bbfc3dd638 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -47,6 +47,15 @@
#include "nm-dhcp4-config.h"
#include "nm-dhcp6-config.h"
+#define _NMLOG_PREFIX_NAME "policy"
+#define _NMLOG(level, domain, ...) \
+ G_STMT_START { \
+ nm_log ((level), (domain), \
+ "%s" _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } G_STMT_END
+
typedef struct {
NMManager *manager;
NMFirewallManager *firewall_manager;
@@ -132,8 +141,8 @@ set_system_hostname (const char *new_hostname, const char *msg)
errno = 0;
ret = gethostname (old_hostname, HOST_NAME_MAX);
if (ret != 0) {
- nm_log_warn (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
- errno, strerror (errno));
+ _LOGW (LOGD_DNS, "couldn't get the system hostname: (%d) %s",
+ errno, strerror (errno));
} else {
/* Don't set the hostname if it isn't actually changing */
if ( (new_hostname && !strcmp (old_hostname, new_hostname))
@@ -143,15 +152,15 @@ set_system_hostname (const char *new_hostname, const char *msg)
name = (new_hostname && strlen (new_hostname)) ? new_hostname : FALLBACK_HOSTNAME4;
- nm_log_info (LOGD_DNS, "Setting system hostname to '%s' (%s)", name, msg);
+ _LOGI (LOGD_DNS, "setting system hostname to '%s' (%s)", name, msg);
ret = sethostname (name, strlen (name));
if (ret != 0) {
int errsv = errno;
- nm_log_warn (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
- name, errsv, strerror (errsv));
+ _LOGW (LOGD_DNS, "couldn't set the system hostname to '%s': (%d) %s",
+ name, errsv, strerror (errsv));
if (errsv == EPERM)
- nm_log_warn (LOGD_DNS, "You should use hostnamed when systemd hardening is in effect!");
+ _LOGW (LOGD_DNS, "you should use hostnamed when systemd hardening is in effect!");
}
return (ret == 0);
@@ -290,8 +299,8 @@ update_system_hostname (NMPolicy *policy, NMDevice *best4, NMDevice *best6)
return;
}
}
- nm_log_warn (LOGD_DNS, "DHCPv4-provided hostname '%s' looks invalid; ignoring it",
- dhcp_hostname);
+ _LOGW (LOGD_DNS, "DHCPv4-provided hostname '%s' looks invalid; ignoring it",
+ dhcp_hostname);
}
}
} else if (best6) {
@@ -309,8 +318,8 @@ update_system_hostname (NMPolicy *policy, NMDevice *best4, NMDevice *best6)
return;
}
}
- nm_log_warn (LOGD_DNS, "DHCPv6-provided hostname '%s' looks invalid; ignoring it",
- dhcp_hostname);
+ _LOGW (LOGD_DNS, "DHCPv6-provided hostname '%s' looks invalid; ignoring it",
+ dhcp_hostname);
}
}
}
@@ -469,8 +478,8 @@ update_ip4_routing (NMPolicy *policy, gboolean force_update)
priv->default_device4 = default_device;
connection = nm_active_connection_get_applied_connection (best_ac);
- nm_log_info (LOGD_CORE, "Policy set '%s' (%s) as default for IPv4 routing and DNS.",
- nm_connection_get_id (connection), ip_iface);
+ _LOGI (LOGD_CORE, "set '%s' (%s) as default for IPv4 routing and DNS",
+ nm_connection_get_id (connection), ip_iface);
g_object_notify (G_OBJECT (policy), NM_POLICY_DEFAULT_IP4_DEVICE);
}
@@ -564,8 +573,8 @@ update_ip6_routing (NMPolicy *policy, gboolean force_update)
priv->default_device6 = default_device6;
connection = nm_active_connection_get_applied_connection (best_ac);
- nm_log_info (LOGD_CORE, "Policy set '%s' (%s) as default for IPv6 routing and DNS.",
- nm_connection_get_id (connection), ip_iface);
+ _LOGI (LOGD_CORE, "set '%s' (%s) as default for IPv6 routing and DNS",
+ nm_connection_get_id (connection), ip_iface);
g_object_notify (G_OBJECT (policy), NM_POLICY_DEFAULT_IP6_DEVICE);
}
@@ -686,8 +695,8 @@ auto_activate_device (gpointer user_data)
GError *error = NULL;
NMAuthSubject *subject;
- nm_log_info (LOGD_DEVICE, "Auto-activating connection '%s'.",
- nm_settings_connection_get_id (best_connection));
+ _LOGI (LOGD_DEVICE, "auto-activating connection '%s'",
+ nm_settings_connection_get_id (best_connection));
subject = nm_auth_subject_new_internal ();
if (!nm_manager_activate_connection (priv->manager,
best_connection,
@@ -695,10 +704,10 @@ auto_activate_device (gpointer user_data)
data->device,
subject,
&error)) {
- nm_log_info (LOGD_DEVICE, "Connection '%s' auto-activation failed: (%d) %s",
- nm_settings_connection_get_id (best_connection),
- error->code,
- error->message);
+ _LOGI (LOGD_DEVICE, "connection '%s' auto-activation failed: (%d) %s",
+ nm_settings_connection_get_id (best_connection),
+ error->code,
+ error->message);
g_error_free (error);
}
g_object_unref (subject);
@@ -773,9 +782,9 @@ process_secondaries (NMPolicy *policy,
continue;
if (connected) {
- nm_log_dbg (LOGD_DEVICE, "Secondary connection '%s' SUCCEEDED; active path '%s'",
- nm_active_connection_get_settings_connection_id (active),
- nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
+ _LOGD (LOGD_DEVICE, "secondary connection '%s' succeeded; active path '%s'",
+ nm_active_connection_get_settings_connection_id (active),
+ nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
/* Secondary connection activated */
secondary_data->secondaries = g_slist_remove (secondary_data->secondaries, secondary_active);
@@ -789,9 +798,9 @@ process_secondaries (NMPolicy *policy,
break;
}
} else {
- nm_log_dbg (LOGD_DEVICE, "Secondary connection '%s' FAILED; active path '%s'",
- nm_active_connection_get_settings_connection_id (active),
- nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
+ _LOGD (LOGD_DEVICE, "secondary connection '%s' failed; active path '%s'",
+ nm_active_connection_get_settings_connection_id (active),
+ nm_exported_object_get_path (NM_EXPORTED_OBJECT (active)));
/* Secondary connection failed -> do not watch other connections */
priv->pending_secondaries = g_slist_remove (priv->pending_secondaries, secondary_data);
@@ -824,10 +833,10 @@ reset_autoconnect_all (NMPolicy *policy, NMDevice *device)
GSList *connections, *iter;
if (device) {
- nm_log_dbg (LOGD_DEVICE, "Re-enabling autoconnect for all connections on %s",
- nm_device_get_iface (device));
+ _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections on %s",
+ nm_device_get_iface (device));
} else
- nm_log_dbg (LOGD_DEVICE, "Re-enabling autoconnect for all connections");
+ _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections");
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = g_slist_next (iter)) {
@@ -845,7 +854,7 @@ reset_autoconnect_for_failed_secrets (NMPolicy *policy)
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
GSList *connections, *iter;
- nm_log_dbg (LOGD_DEVICE, "Re-enabling autoconnect for all connections with failed secrets");
+ _LOGD (LOGD_DEVICE, "re-enabling autoconnect for all connections with failed secrets");
connections = nm_settings_get_connections (priv->settings);
for (iter = connections; iter; iter = g_slist_next (iter)) {
@@ -865,8 +874,8 @@ block_autoconnect_for_device (NMPolicy *policy, NMDevice *device)
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
GSList *connections, *iter;
- nm_log_dbg (LOGD_DEVICE, "Blocking autoconnect for all connections on %s",
- nm_device_get_iface (device));
+ _LOGD (LOGD_DEVICE, "blocking autoconnect for all connections on %s",
+ nm_device_get_iface (device));
/* NMDevice keeps its own autoconnect-able-ness state; we only need to
* explicitly block connections for software devices, where the NMDevice
@@ -1061,14 +1070,14 @@ activate_secondary_connections (NMPolicy *policy,
settings_con = nm_settings_get_connection_by_uuid (priv->settings, sec_uuid);
if (!settings_con) {
- nm_log_warn (LOGD_DEVICE, "Secondary connection '%s' auto-activation failed: The connection doesn't exist.",
- sec_uuid);
+ _LOGW (LOGD_DEVICE, "secondary connection '%s' auto-activation failed: The connection doesn't exist.",
+ sec_uuid);
success = FALSE;
break;
}
if (!nm_connection_is_type (NM_CONNECTION (settings_con), NM_SETTING_VPN_SETTING_NAME)) {
- nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: The connection is not a VPN.",
- nm_settings_connection_get_id (settings_con), sec_uuid);
+ _LOGW (LOGD_DEVICE, "secondary connection '%s (%s)' auto-activation failed: The connection is not a VPN.",
+ nm_settings_connection_get_id (settings_con), sec_uuid);
success = FALSE;
break;
}
@@ -1076,9 +1085,9 @@ activate_secondary_connections (NMPolicy *policy,
req = nm_device_get_act_request (device);
g_assert (req);
- nm_log_dbg (LOGD_DEVICE, "Activating secondary connection '%s (%s)' for base connection '%s (%s)'",
- nm_settings_connection_get_id (settings_con), sec_uuid,
- nm_connection_get_id (connection), nm_connection_get_uuid (connection));
+ _LOGD (LOGD_DEVICE, "activating secondary connection '%s (%s)' for base connection '%s (%s)'",
+ nm_settings_connection_get_id (settings_con), sec_uuid,
+ nm_connection_get_id (connection), nm_connection_get_uuid (connection));
ac = nm_manager_activate_connection (priv->manager,
settings_con,
nm_exported_object_get_path (NM_EXPORTED_OBJECT (req)),
@@ -1088,10 +1097,10 @@ activate_secondary_connections (NMPolicy *policy,
if (ac)
secondary_ac_list = g_slist_append (secondary_ac_list, g_object_ref (ac));
else {
- nm_log_warn (LOGD_DEVICE, "Secondary connection '%s (%s)' auto-activation failed: (%d) %s",
- nm_settings_connection_get_id (settings_con), sec_uuid,
- error->code,
- error->message);
+ _LOGW (LOGD_DEVICE, "secondary connection '%s (%s)' auto-activation failed: (%d) %s",
+ nm_settings_connection_get_id (settings_con), sec_uuid,
+ error->code,
+ error->message);
g_clear_error (&error);
success = FALSE;
break;
@@ -1135,19 +1144,19 @@ device_state_changed (NMDevice *device,
guint32 tries = nm_settings_connection_get_autoconnect_retries (connection);
if (reason == NM_DEVICE_STATE_REASON_NO_SECRETS) {
- nm_log_dbg (LOGD_DEVICE, "Connection '%s' now blocked from autoconnect due to no secrets",
- nm_settings_connection_get_id (connection));
+ _LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
+ nm_settings_connection_get_id (connection));
nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NO_SECRETS);
} else if (tries > 0) {
- nm_log_dbg (LOGD_DEVICE, "Connection '%s' failed to autoconnect; %d tries left",
- nm_settings_connection_get_id (connection), tries);
+ _LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",
+ nm_settings_connection_get_id (connection), tries);
nm_settings_connection_set_autoconnect_retries (connection, tries - 1);
}
if (nm_settings_connection_get_autoconnect_retries (connection) == 0) {
- nm_log_info (LOGD_DEVICE, "Disabling autoconnect for connection '%s'.",
- nm_settings_connection_get_id (connection));
+ _LOGI (LOGD_DEVICE, "disabling autoconnect for connection '%s'.",
+ nm_settings_connection_get_id (connection));
/* Schedule a handler to reset retries count */
if (!priv->reset_retries_id) {
gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);
@@ -1199,8 +1208,8 @@ device_state_changed (NMDevice *device,
} else {
if (connection) {
/* The connection was deactivated, so block just this connection */
- nm_log_dbg (LOGD_DEVICE, "Blocking autoconnect of connection '%s' by user request",
- nm_settings_connection_get_id (connection));
+ _LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s' by user request",
+ nm_settings_connection_get_id (connection));
nm_settings_connection_set_autoconnect_blocked_reason (connection,
NM_DEVICE_STATE_REASON_USER_REQUESTED);
}
@@ -1491,9 +1500,9 @@ vpn_connection_retry_after_failure (NMVpnConnection *vpn, NMPolicy *policy)
NULL,
nm_active_connection_get_subject (ac),
&error)) {
- nm_log_warn (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
- nm_settings_connection_get_id (connection),
- error->message ? error->message : "unknown");
+ _LOGW (LOGD_DEVICE, "VPN '%s' reconnect failed: %s",
+ nm_settings_connection_get_id (connection),
+ error->message ? error->message : "unknown");
g_clear_error (&error);
}
}
@@ -1606,8 +1615,8 @@ dns_config_changed (NMDnsManager *dns_manager, gpointer user_data)
if (priv->lookup_addr) {
char *str = NULL;
- nm_log_dbg (LOGD_DNS, "restarting reverse-lookup thread for address %s",
- (str = g_inet_address_to_string (priv->lookup_addr)));
+ _LOGD (LOGD_DNS, "restarting reverse-lookup thread for address %s",
+ (str = g_inet_address_to_string (priv->lookup_addr)));
g_free (str);
priv->lookup_cancellable = g_cancellable_new ();
@@ -1670,10 +1679,10 @@ _deactivate_if_active (NMManager *manager, NMSettingsConnection *connection)
nm_exported_object_get_path (NM_EXPORTED_OBJECT (ac)),
NM_DEVICE_STATE_REASON_CONNECTION_REMOVED,
&error)) {
- nm_log_warn (LOGD_DEVICE, "Connection '%s' disappeared, but error deactivating it: (%d) %s",
- nm_settings_connection_get_id (connection),
- error ? error->code : -1,
- error ? error->message : "(unknown)");
+ _LOGW (LOGD_DEVICE, "connection '%s' disappeared, but error deactivating it: (%d) %s",
+ nm_settings_connection_get_id (connection),
+ error ? error->code : -1,
+ error ? error->message : "(unknown)");
g_clear_error (&error);
}
}
diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c
index 1578e595fc..16e34f11e5 100644
--- a/src/ppp-manager/nm-ppp-manager.c
+++ b/src/ppp-manager/nm-ppp-manager.c
@@ -49,6 +49,16 @@
#include "nmdbus-ppp-manager.h"
+#define _NMLOG_DOMAIN LOGD_PPP
+#define _NMLOG_PREFIX_NAME "ppp-manager"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
static void _ppp_cleanup (NMPPPManager *manager);
static void _ppp_kill (NMPPPManager *manager);
@@ -185,7 +195,7 @@ monitor_cb (gpointer user_data)
strncpy (req.ifr_name, priv->ip_iface, sizeof (req.ifr_name));
if (ioctl (priv->monitor_fd, SIOCGPPPSTATS, &req) < 0) {
if (errno != ENODEV)
- nm_log_warn (LOGD_PPP, "could not read ppp stats: %s", strerror (errno));
+ _LOGW ("could not read ppp stats: %s", strerror (errno));
} else {
g_signal_emit (manager, signals[STATS], 0,
stats.p.ppp_ibytes,
@@ -211,7 +221,7 @@ monitor_stats (NMPPPManager *manager)
g_source_remove (priv->monitor_id);
priv->monitor_id = g_timeout_add_seconds (5, monitor_cb, manager);
} else
- nm_log_warn (LOGD_PPP, "could not monitor PPP stats: %s", strerror (errno));
+ _LOGW ("could not monitor PPP stats: %s", strerror (errno));
}
/*******************************************/
@@ -316,7 +326,7 @@ ppp_secrets_cb (NMActRequest *req,
goto out;
if (error) {
- nm_log_warn (LOGD_PPP, "%s", error->message);
+ _LOGW ("%s", error->message);
g_dbus_method_invocation_return_gerror (priv->pending_secrets_context, error);
goto out;
}
@@ -324,7 +334,7 @@ ppp_secrets_cb (NMActRequest *req,
applied_connection = nm_act_request_get_applied_connection (req);
if (!extract_details_from_connection (applied_connection, priv->secrets_setting_name, &username, &password, &local)) {
- nm_log_warn (LOGD_PPP, "%s", local->message);
+ _LOGW ("%s", local->message);
g_dbus_method_invocation_take_error (priv->pending_secrets_context, local);
goto out;
}
@@ -370,7 +380,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager,
priv->pending_secrets_context = context;
ppp_secrets_cb (priv->act_req, priv->secrets_id, NULL, NULL, manager);
} else {
- nm_log_warn (LOGD_PPP, "%s", error->message);
+ _LOGW ("%s", error->message);
g_dbus_method_invocation_take_error (priv->pending_secrets_context, error);
}
return;
@@ -419,7 +429,7 @@ set_ip_config_common (NMPPPManager *self,
const char *iface;
if (!g_variant_lookup (config_dict, iface_prop, "&s", &iface)) {
- nm_log_err (LOGD_PPP, "no interface received!");
+ _LOGE ("no interface received!");
return FALSE;
}
if (priv->ip_iface == NULL)
@@ -450,7 +460,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
guint32 u32;
GVariantIter *iter;
- nm_log_info (LOGD_PPP, "PPP manager (IPv4 Config Get) reply received.");
+ _LOGI ("(IPv4 Config Get) reply received.");
remove_timeout_handler (manager);
@@ -475,7 +485,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
address.source = NM_IP_CONFIG_SOURCE_PPP;
nm_ip4_config_add_address (config, &address);
} else {
- nm_log_err (LOGD_PPP, "invalid IPv4 address received!");
+ _LOGE ("invalid IPv4 address received!");
goto out;
}
@@ -517,7 +527,7 @@ iid_value_to_ll6_addr (GVariant *dict,
guint64 iid;
if (!g_variant_lookup (dict, prop, "t", &iid)) {
- nm_log_dbg (LOGD_PPP, "pppd plugin property '%s' missing or not a uint64", prop);
+ _LOGD ("pppd plugin property '%s' missing or not a uint64", prop);
return FALSE;
}
g_return_val_if_fail (iid != 0, FALSE);
@@ -545,7 +555,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
struct in6_addr a;
NMUtilsIPv6IfaceId iid = NM_UTILS_IPV6_IFACE_ID_INIT;
- nm_log_info (LOGD_PPP, "PPP manager (IPv6 Config Get) reply received.");
+ _LOGI ("(IPv6 Config Get) reply received.");
remove_timeout_handler (manager);
@@ -567,7 +577,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager,
g_signal_emit (manager, signals[IP6_CONFIG], 0, priv->ip_iface, &iid, config);
}
} else
- nm_log_err (LOGD_PPP, "invalid IPv6 address received!");
+ _LOGE ("invalid IPv6 address received!");
g_object_unref (config);
g_dbus_method_invocation_return_value (context, NULL);
@@ -771,7 +781,7 @@ ppp_exit_code (guint pppd_exit_status, GPid pid)
msg = "Unknown error";
}
- nm_log_warn (LOGD_PPP, "pppd pid %d exited with error: %s", pid, msg);
+ _LOGW ("pppd pid %d exited with error: %s", pid, msg);
}
static void
@@ -788,13 +798,13 @@ ppp_watch_cb (GPid pid, gint status, gpointer user_data)
if (err != 0)
ppp_exit_code (err, priv->pid);
} else if (WIFSTOPPED (status)) {
- nm_log_info (LOGD_PPP, "pppd pid %d stopped unexpectedly with signal %d", priv->pid, WSTOPSIG (status));
+ _LOGI ("pppd pid %d stopped unexpectedly with signal %d", priv->pid, WSTOPSIG (status));
} else if (WIFSIGNALED (status)) {
- nm_log_info (LOGD_PPP, "pppd pid %d died with signal %d", priv->pid, WTERMSIG (status));
+ _LOGI ("pppd pid %d died with signal %d", priv->pid, WTERMSIG (status));
} else
- nm_log_info (LOGD_PPP, "pppd pid %d died from an unknown cause", priv->pid);
+ _LOGI ("pppd pid %d died from an unknown cause", priv->pid);
- nm_log_dbg (LOGD_PPP, "pppd pid %d cleaned up", priv->pid);
+ _LOGD ("pppd pid %d cleaned up", priv->pid);
priv->pid = 0;
priv->ppp_watch_id = 0;
g_signal_emit (manager, signals[STATE_CHANGED], 0, NM_PPP_STATUS_DEAD);
@@ -805,7 +815,7 @@ pppd_timed_out (gpointer data)
{
NMPPPManager *manager = NM_PPP_MANAGER (data);
- nm_log_warn (LOGD_PPP, "pppd timed out or didn't initialize our dbus module");
+ _LOGW ("pppd timed out or didn't initialize our dbus module");
_ppp_cleanup (manager);
_ppp_kill (manager);
@@ -1065,10 +1075,10 @@ nm_ppp_manager_start (NMPPPManager *manager,
g_ptr_array_add (ppp_cmd->array, NULL);
- nm_log_info (LOGD_PPP, "starting PPP connection");
+ _LOGI ("starting PPP connection");
cmd_str = nm_cmd_line_to_str (ppp_cmd);
- nm_log_dbg (LOGD_PPP, "command line: %s", cmd_str);
+ _LOGD ("command line: %s", cmd_str);
g_free (cmd_str);
priv->pid = 0;
@@ -1079,7 +1089,7 @@ nm_ppp_manager_start (NMPPPManager *manager,
goto out;
}
- nm_log_info (LOGD_PPP, "pppd started with pid %d", priv->pid);
+ _LOGI ("pppd started with pid %d", priv->pid);
priv->ppp_watch_id = g_child_watch_add (priv->pid, (GChildWatchFunc) ppp_watch_cb, manager);
priv->ppp_timeout_handler = g_timeout_add_seconds (timeout_secs, pppd_timed_out, manager);
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 07a8c2e642..f9bac4ded6 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -76,12 +76,15 @@
#include "nmdbus-settings.h"
-#define LOG(level, ...) \
- G_STMT_START { \
- nm_log ((level), LOGD_CORE, \
- "settings: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__) \
- _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
- } G_STMT_END
+#define _NMLOG_DOMAIN LOGD_SETTINGS
+#define _NMLOG_PREFIX_NAME "settings"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
/* LINKER CRACKROCK */
#define EXPORT(sym) void * __export_##sym = &sym;
@@ -652,8 +655,8 @@ add_plugin (NMSettings *self, NMSettingsPlugin *plugin)
path = g_object_get_data (G_OBJECT (plugin), PLUGIN_MODULE_PATH);
- nm_log_info (LOGD_SETTINGS, "Loaded settings plugin %s: %s%s%s%s", pname, pinfo,
- NM_PRINT_FMT_QUOTED (path, " (", path, ")", ""));
+ _LOGI ("loaded plugin %s: %s%s%s%s", pname, pinfo,
+ NM_PRINT_FMT_QUOTED (path, " (", path, ")", ""));
g_free (pname);
g_free (pinfo);
@@ -719,12 +722,12 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
GObject *obj;
if (!*pname || strchr (pname, '/')) {
- LOG (LOGL_WARN, "ignore invalid plugin \"%s\"", pname);
+ _LOGW ("ignore invalid plugin \"%s\"", pname);
continue;
}
if (!strcmp (pname, "ifcfg-suse")) {
- LOG (LOGL_WARN, "skipping deprecated plugin ifcfg-suse");
+ _LOGW ("skipping deprecated plugin ifcfg-suse");
continue;
}
@@ -767,25 +770,25 @@ load_plugin:
if (stat (path, &st) != 0) {
errsv = errno;
- LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s", pname, path, strerror (errsv));
+ _LOGW ("could not load plugin '%s' from file '%s': %s", pname, path, strerror (errsv));
goto next;
}
if (!S_ISREG (st.st_mode)) {
- LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': not a file", pname, path);
+ _LOGW ("could not load plugin '%s' from file '%s': not a file", pname, path);
goto next;
}
if (st.st_uid != 0) {
- LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': file must be owned by root", pname, path);
+ _LOGW ("could not load plugin '%s' from file '%s': file must be owned by root", pname, path);
goto next;
}
if (st.st_mode & (S_IWGRP | S_IWOTH | S_ISUID)) {
- LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': invalid file permissions", pname, path);
+ _LOGW ("could not load plugin '%s' from file '%s': invalid file permissions", pname, path);
goto next;
}
plugin = g_module_open (path, G_MODULE_BIND_LOCAL);
if (!plugin) {
- LOG (LOGL_WARN, "Could not load plugin '%s' from file '%s': %s",
+ _LOGW ("could not load plugin '%s' from file '%s': %s",
pname, path, g_module_error ());
goto next;
}
@@ -985,8 +988,7 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
}
if (!nm_connection_normalize (NM_CONNECTION (connection), NULL, NULL, &error)) {
- nm_log_warn (LOGD_SETTINGS, "plugin provided invalid connection: %s",
- error->message);
+ _LOGW ("plugin provided invalid connection: %s", error->message);
g_error_free (error);
return;
}
@@ -1003,8 +1005,8 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
* without the individual plugins being aware. Don't handle that at all, just
* error out. That should not happen unless the admin misconfigured the system
* to create conflicting connections. */
- nm_log_warn (LOGD_SETTINGS, "plugin provided duplicate connection with UUID %s",
- nm_settings_connection_get_uuid (connection));
+ _LOGW ("plugin provided duplicate connection with UUID %s",
+ nm_settings_connection_get_uuid (connection));
return;
}
@@ -1117,10 +1119,10 @@ nm_settings_add_connection (NMSettings *self,
claim_connection (self, added);
return added;
}
- nm_log_dbg (LOGD_SETTINGS, "Failed to add %s/'%s': %s",
- nm_connection_get_uuid (connection),
- nm_connection_get_id (connection),
- add_error->message);
+ _LOGD ("Failed to add %s/'%s': %s",
+ nm_connection_get_uuid (connection),
+ nm_connection_get_id (connection),
+ add_error->message);
g_clear_error (&add_error);
}
@@ -1492,7 +1494,7 @@ impl_settings_load_connections (NMSettings *self,
if (!iter) {
if (!g_path_is_absolute (filenames[i]))
- nm_log_warn (LOGD_SETTINGS, "Connection filename '%s' is not an absolute path", filenames[i]);
+ _LOGW ("connection filename '%s' is not an absolute path", filenames[i]);
g_ptr_array_add (failures, (char *) filenames[i]);
}
}
@@ -1549,7 +1551,7 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname)
NULL,
&error);
if (error)
- nm_log_warn (LOGD_SETTINGS, "Could not set hostname: %s", error->message);
+ _LOGW ("could not set hostname: %s", error->message);
return !error;
}
@@ -1595,7 +1597,7 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname)
g_free (hostname_eol);
if (!ret) {
- nm_log_warn (LOGD_SETTINGS, "Could not save hostname to %s: %s", file, error->message);
+ _LOGW ("could not save hostname to %s: %s", file, error->message);
return FALSE;
}
@@ -1721,9 +1723,9 @@ hostname_maybe_changed (NMSettings *settings)
|| (!new_hostname && priv->hostname.value)
|| (priv->hostname.value && new_hostname && strcmp (priv->hostname.value, new_hostname))) {
- nm_log_info (LOGD_SETTINGS, "hostname changed from %s%s%s to %s%s%s",
- NM_PRINT_FMT_QUOTED (priv->hostname.value, "\"", priv->hostname.value, "\"", "(none)"),
- NM_PRINT_FMT_QUOTED (new_hostname, "\"", new_hostname, "\"", "(none)"));
+ _LOGI ("hostname changed from %s%s%s to %s%s%s",
+ NM_PRINT_FMT_QUOTED (priv->hostname.value, "\"", priv->hostname.value, "\"", "(none)"),
+ NM_PRINT_FMT_QUOTED (new_hostname, "\"", new_hostname, "\"", "(none)"));
g_free (priv->hostname.value);
priv->hostname.value = new_hostname;
g_object_notify (G_OBJECT (settings), NM_SETTINGS_HOSTNAME);
@@ -1894,9 +1896,9 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
g_object_unref (connection);
if (!added) {
- nm_log_warn (LOGD_SETTINGS, "(%s) couldn't create default wired connection: %s",
- nm_device_get_iface (device),
- error->message);
+ _LOGW ("(%s) couldn't create default wired connection: %s",
+ nm_device_get_iface (device),
+ error->message);
g_clear_error (&error);
return;
}
@@ -1909,9 +1911,9 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self)
g_signal_connect (added, NM_SETTINGS_CONNECTION_REMOVED,
G_CALLBACK (default_wired_connection_removed_cb), self);
- nm_log_info (LOGD_SETTINGS, "(%s): created default wired connection '%s'",
- nm_device_get_iface (device),
- nm_settings_connection_get_id (added));
+ _LOGI ("(%s): created default wired connection '%s'",
+ nm_device_get_iface (device),
+ nm_settings_connection_get_id (added));
}
void
@@ -2080,9 +2082,9 @@ hostnamed_properties_changed (GDBusProxy *proxy,
hostname = g_variant_get_string (v_hostname, NULL);
if (g_strcmp0 (priv->hostname.value, hostname) != 0) {
- nm_log_info (LOGD_SETTINGS, "hostname changed from %s%s%s to %s%s%s",
- NM_PRINT_FMT_QUOTED (priv->hostname.value, "\"", priv->hostname.value, "\"", "(none)"),
- NM_PRINT_FMT_QUOTED (hostname, "\"", hostname, "\"", "(none)"));
+ _LOGI ("hostname changed from %s%s%s to %s%s%s",
+ NM_PRINT_FMT_QUOTED (priv->hostname.value, "\"", priv->hostname.value, "\"", "(none)"),
+ NM_PRINT_FMT_QUOTED (hostname, "\"", hostname, "\"", "(none)"));
g_free (priv->hostname.value);
priv->hostname.value = g_strdup (hostname);
g_object_notify (G_OBJECT (user_data), NM_SETTINGS_HOSTNAME);
@@ -2170,19 +2172,19 @@ nm_settings_start (NMSettings *self, GError **error)
if (proxy) {
variant = g_dbus_proxy_get_cached_property (proxy, "StaticHostname");
if (variant) {
- nm_log_info (LOGD_SETTINGS, "hostname: using hostnamed");
+ _LOGI ("hostname: using hostnamed");
priv->hostname.hostnamed_proxy = proxy;
g_signal_connect (proxy, "g-properties-changed",
G_CALLBACK (hostnamed_properties_changed), self);
hostnamed_properties_changed (proxy, NULL, NULL, self);
g_variant_unref (variant);
} else {
- nm_log_info (LOGD_SETTINGS, "hostname: couldn't get property from hostnamed");
+ _LOGI ("hostname: couldn't get property from hostnamed");
g_object_unref (proxy);
}
} else {
- nm_log_info (LOGD_SETTINGS, "hostname: hostnamed not used as proxy creation failed with: %s",
- local_error->message);
+ _LOGI ("hostname: hostnamed not used as proxy creation failed with: %s",
+ local_error->message);
g_clear_error (&local_error);
}
diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c
index 1b352527c7..f2c63364f3 100644
--- a/src/supplicant-manager/nm-supplicant-manager.c
+++ b/src/supplicant-manager/nm-supplicant-manager.c
@@ -34,6 +34,16 @@
G_DEFINE_TYPE (NMSupplicantManager, nm_supplicant_manager, G_TYPE_OBJECT)
+#define _NMLOG_DOMAIN LOGD_SUPPLICANT
+#define _NMLOG_PREFIX_NAME "supplicant"
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ nm_log ((level), _NMLOG_DOMAIN, \
+ "%s" _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME": " \
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
typedef struct {
GDBusProxy * proxy;
GCancellable * cancellable;
@@ -133,7 +143,7 @@ nm_supplicant_manager_create_interface (NMSupplicantManager *self,
priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);
- nm_log_dbg (LOGD_SUPPLICANT, "(%s): creating new supplicant interface", ifname);
+ _LOGD ("(%s): creating new supplicant interface", ifname);
/* assert against not requesting duplicate interfaces. */
for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next) {
@@ -195,9 +205,9 @@ update_capabilities (NMSupplicantManager *self)
for (ifaces = priv->ifaces; ifaces; ifaces = ifaces->next)
nm_supplicant_interface_set_ap_support (ifaces->data, priv->ap_support);
- nm_log_dbg (LOGD_SUPPLICANT, "AP mode is %ssupported",
- (priv->ap_support == NM_SUPPLICANT_FEATURE_YES) ? "" :
- (priv->ap_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly ");
+ _LOGD ("AP mode is %ssupported",
+ (priv->ap_support == NM_SUPPLICANT_FEATURE_YES) ? "" :
+ (priv->ap_support == NM_SUPPLICANT_FEATURE_NO) ? "not " : "possibly ");
/* EAP-FAST */
priv->fast_supported = FALSE;
@@ -212,7 +222,7 @@ update_capabilities (NMSupplicantManager *self)
g_variant_unref (value);
}
- nm_log_dbg (LOGD_SUPPLICANT, "EAP-FAST is %ssupported", priv->fast_supported ? "" : "not ");
+ _LOGD ("EAP-FAST is %ssupported", priv->fast_supported ? "" : "not ");
}
static void
@@ -270,7 +280,7 @@ wpas_die_count_reset_cb (gpointer user_data)
/* Reset the die count back to zero, which allows use of the supplicant again */
priv->die_count_reset_id = 0;
set_die_count (self, 0);
- nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant die count reset");
+ _LOGI ("wpa_supplicant die count reset");
return FALSE;
}
@@ -284,7 +294,7 @@ name_owner_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data)
g_return_if_fail (proxy == priv->proxy);
owner = g_dbus_proxy_get_name_owner (proxy);
- nm_log_info (LOGD_SUPPLICANT, "wpa_supplicant %s", owner ? "running" : "stopped");
+ _LOGI ("wpa_supplicant %s", owner ? "running" : "stopped");
if (owner) {
set_running (self, TRUE);
@@ -301,9 +311,8 @@ name_owner_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data)
set_die_count (self, priv->die_count + 1);
if (die_count_exceeded (priv->die_count)) {
- nm_log_info (LOGD_SUPPLICANT,
- "wpa_supplicant die count %d; ignoring for 10 seconds",
- priv->die_count);
+ _LOGI ("wpa_supplicant die count %d; ignoring for 10 seconds",
+ priv->die_count);
}
set_running (self, FALSE);
@@ -324,9 +333,8 @@ on_proxy_acquired (GObject *object, GAsyncResult *result, gpointer user_data)
proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
if (!proxy) {
- nm_log_warn (LOGD_SUPPLICANT,
- "Failed to acquire wpa_supplicant proxy: Wi-Fi and 802.1x will not be available (%s)",
- error->message);
+ _LOGW ("failed to acquire wpa_supplicant proxy: Wi-Fi and 802.1x will not be available (%s)",
+ error->message);
g_clear_error (&error);
return;
}