summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-07-08 19:34:34 +0200
committerThomas Haller <thaller@redhat.com>2015-07-12 14:49:04 +0200
commit3d282f463726598e97e6119bb9edc84bc2673d7b (patch)
treecedbdaa6d455ed6ca5b7cd9df3ee85278c02f524
parentf9500142f98d2ff17d0015acfed0c3e5fee5b4dd (diff)
downloadNetworkManager-3d282f463726598e97e6119bb9edc84bc2673d7b.tar.gz
logging: make use of journal configurable
-rw-r--r--man/NetworkManager.conf.xml.in12
-rw-r--r--src/devices/nm-device.c12
-rw-r--r--src/main.c7
-rw-r--r--src/nm-config.h1
-rw-r--r--src/nm-iface-helper.c6
-rw-r--r--src/nm-logging.c6
-rw-r--r--src/nm-logging.h2
7 files changed, 40 insertions, 6 deletions
diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in
index bf15c9e8b5..e16932228e 100644
--- a/man/NetworkManager.conf.xml.in
+++ b/man/NetworkManager.conf.xml.in
@@ -470,6 +470,18 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth
</simplelist>
</para>
</varlistentry>
+ <varlistentry>
+ <term><varname>backend</varname></term>
+ <listitem><para>The logging backend. Supported values
+ are "<literal>debug</literal>", "<literal>syslog</literal>" and
+ "<literal>journal</literal>". "<literal>debug</literal>" uses syslog
+ and logs to standard error.
+ If NetworkManager is started in debug mode (<literal>--debug</literal>)
+ this option is ignored and we always use "<literal>debug</literal>".
+ Otherwise, the default is "<literal>journal</literal>" if NetworkManager
+ was compiled with systemd journal support.
+ </para></listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect1>
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 48d2004fe6..8207cd1557 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -8075,6 +8075,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
const char *method;
GPtrArray *argv;
gs_free char *dhcp4_address = NULL;
+ char *logging_backend;
if (priv->state != NM_DEVICE_STATE_ACTIVATED)
return;
@@ -8093,6 +8094,17 @@ nm_device_spawn_iface_helper (NMDevice *self)
g_ptr_array_add (argv, g_strdup ("--uuid"));
g_ptr_array_add (argv, g_strdup (nm_connection_get_uuid (connection)));
+ logging_backend = nm_config_get_is_debug (nm_config_get ())
+ ? g_strdup ("debug")
+ : nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
+ NM_CONFIG_KEYFILE_GROUP_LOGGING,
+ NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND,
+ NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
+ if (logging_backend) {
+ g_ptr_array_add (argv, g_strdup ("--logging-backend"));
+ g_ptr_array_add (argv, logging_backend);
+ }
+
dhcp4_address = find_dhcp4_address (self);
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
diff --git a/src/main.c b/src/main.c
index 7b1e522467..27babf81ec 100644
--- a/src/main.c
+++ b/src/main.c
@@ -386,7 +386,12 @@ main (int argc, char *argv[])
/* Set up unix signal handling - before creating threads, but after daemonizing! */
nm_main_utils_setup_signals (main_loop);
- nm_logging_syslog_openlog (nm_config_get_is_debug (config));
+ nm_logging_syslog_openlog (nm_config_get_is_debug (config)
+ ? "debug"
+ : nm_config_data_get_value_cached (NM_CONFIG_GET_DATA_ORIG,
+ NM_CONFIG_KEYFILE_GROUP_LOGGING,
+ NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND,
+ NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY));
nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting...");
diff --git a/src/nm-config.h b/src/nm-config.h
index 113664e79e..870d4e4fe5 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -61,6 +61,7 @@ G_BEGIN_DECLS
#define NM_CONFIG_KEYFILE_GROUP_IFUPDOWN "ifupdown"
#define NM_CONFIG_KEYFILE_GROUP_IFNET "ifnet"
+#define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was"
#define NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH "auto_refresh"
#define NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED "managed"
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 6a03b1c49f..15a32a4ec2 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -72,6 +72,7 @@ static struct {
char *dhcp4_clientid;
char *dhcp4_hostname;
char *iid_str;
+ char *logging_backend;
char *opt_log_level;
char *opt_log_domains;
guint32 priority_v4;
@@ -294,6 +295,7 @@ do_early_setup (int *argc, char **argv[])
{ "priority4", '\0', 0, G_OPTION_ARG_INT64, &priority64_v4, N_("Route priority for IPv4"), N_("0") },
{ "priority6", '\0', 0, G_OPTION_ARG_INT64, &priority64_v6, N_("Route priority for IPv6"), N_("1024") },
{ "iid", 'e', 0, G_OPTION_ARG_STRING, &global_opt.iid_str, N_("Hex-encoded Interface Identifier"), "" },
+ { "logging-backend", '\0', 0, G_OPTION_ARG_STRING, &global_opt.logging_backend, N_("The logging backend configuration value. See logging.backend in NetworkManager.conf"), NULL },
/* Logging/debugging */
{ "version", 'V', 0, G_OPTION_ARG_NONE, &global_opt.show_version, N_("Print NetworkManager version and exit"), NULL },
@@ -405,7 +407,9 @@ main (int argc, char *argv[])
main_loop = g_main_loop_new (NULL, FALSE);
setup_signals ();
- nm_logging_syslog_openlog (global_opt.debug);
+ nm_logging_syslog_openlog (global_opt.logging_backend
+ ? global_opt.logging_backend
+ : (global_opt.debug ? "debug" : NULL));
nm_log_info (LOGD_CORE, "nm-iface-helper (version " NM_DIST_VERSION ") is starting...");
diff --git a/src/nm-logging.c b/src/nm-logging.c
index 2e61f5f7a6..300b51d653 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -627,16 +627,16 @@ nm_log_handler (const gchar *log_domain,
}
void
-nm_logging_syslog_openlog (gboolean debug)
+nm_logging_syslog_openlog (const char *logging_backend)
{
if (log_backend != LOG_BACKEND_GLIB)
g_return_if_reached ();
- if (debug) {
+ if (g_strcmp0 (logging_backend, "debug") == 0) {
log_backend = LOG_BACKEND_SYSLOG;
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
#if SYSTEMD_JOURNAL
- } else if (TRUE) {
+ } else if (g_strcmp0 (logging_backend, "syslog") != 0) {
log_backend = LOG_BACKEND_JOURNAL;
/* ensure we read a monotonic timestamp. Reading the timestamp the first
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 7ed966f85a..c34ef4559b 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -163,6 +163,6 @@ gboolean nm_logging_setup (const char *level,
const char *domains,
char **bad_domains,
GError **error);
-void nm_logging_syslog_openlog (gboolean debug);
+void nm_logging_syslog_openlog (const char *logging_backend);
#endif /* __NETWORKMANAGER_LOGGING_H__ */