diff options
author | Thomas Haller <thaller@redhat.com> | 2015-07-08 21:44:01 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-07-14 15:55:14 +0200 |
commit | f7581bbedcde79bc57617547b279613cd2ac6a35 (patch) | |
tree | a5c91b691df76c609f1dc7fa55b2818601664ce9 | |
parent | 533a08359e5a9e1fb7da3e3a0d19b44deb65707d (diff) | |
download | NetworkManager-f7581bbedcde79bc57617547b279613cd2ac6a35.tar.gz |
logging: add compile time default for logging.backend configuration
-rw-r--r-- | configure.ac | 22 | ||||
-rw-r--r-- | man/NetworkManager.conf.xml.in | 3 | ||||
-rw-r--r-- | src/nm-logging.c | 9 |
3 files changed, 28 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 11f6ccdaad..9d5ad54719 100644 --- a/configure.ac +++ b/configure.ac @@ -400,6 +400,26 @@ else AC_DEFINE([SYSTEMD_JOURNAL], 0, [Define to 1 if libsystemd-journald is available]) fi +AC_ARG_WITH(config-logging-backend-default, AS_HELP_STRING([--with-logging-backend-default=backend], [Default value for logging.backend]), nm_config_logging_backend_default="$withval", nm_config_logging_backend_default="") +if test "$nm_config_logging_backend_default" != 'debug' \ + -a "$nm_config_logging_backend_default" != 'syslog' \ + -a "$nm_config_logging_backend_default" != 'journal' \ + -a "$nm_config_logging_backend_default" != 'journal-syslog-style'; then + # unknown backend. Reset to default. Silently accept the invalid value to + # be future proof. + nm_config_logging_backend_default='' +fi +if test "$nm_config_logging_backend_default" = ""; then + if test "$have_systemd_journal" = "yes"; then + nm_config_logging_backend_default='journal-syslog-style' + else + nm_config_logging_backend_default='syslog' + fi +fi +AC_DEFINE_UNQUOTED(NM_CONFIG_LOGGING_BACKEND_DEFAULT, "$nm_config_logging_backend_default", [Default configuration option for logging.backend]) +NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT="$nm_config_logging_backend_default" +AC_SUBST(NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT) + # Session tracking support AC_ARG_WITH(systemd-logind, AS_HELP_STRING([--with-systemd-logind=yes|no], [Support systemd session tracking])) @@ -1115,7 +1135,7 @@ else fi echo " polkit agent: ${enable_polkit_agent}" echo " selinux: $have_selinux" -echo " systemd-journald: $have_systemd_journal" +echo " systemd-journald: $have_systemd_journal (logging.backend: ${nm_config_logging_backend_default})" echo " hostname persist: ${hostname_persist}" echo diff --git a/man/NetworkManager.conf.xml.in b/man/NetworkManager.conf.xml.in index 3b308253f8..4d4c8a293f 100644 --- a/man/NetworkManager.conf.xml.in +++ b/man/NetworkManager.conf.xml.in @@ -481,8 +481,7 @@ unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth fields in the text. If NetworkManager is started in debug mode (<literal>--debug</literal>) this option is ignored and "<literal>debug</literal>" is always used. - Otherwise, the default is "<literal>journal-syslog-style</literal>" if - NetworkManager was compiled with systemd journal support. + Otherwise, the default is "<literal>@NM_CONFIG_LOGGING_BACKEND_DEFAULT_TEXT@</literal>". </para></listitem> </varlistentry> </variablelist> diff --git a/src/nm-logging.c b/src/nm-logging.c index c1a81e0d0c..17d820a3fb 100644 --- a/src/nm-logging.c +++ b/src/nm-logging.c @@ -640,12 +640,15 @@ nm_logging_syslog_openlog (const char *logging_backend) if (log_backend != LOG_BACKEND_GLIB) g_return_if_reached (); - if (g_strcmp0 (logging_backend, "debug") == 0) { + if (!logging_backend) + logging_backend = ""NM_CONFIG_LOGGING_BACKEND_DEFAULT; + + if (strcmp (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 (g_strcmp0 (logging_backend, "syslog") != 0) { - if (g_strcmp0 (logging_backend, "journal-syslog-style") != 0) + } else if (strcmp (logging_backend, "syslog") != 0) { + if (strcmp (logging_backend, "journal-syslog-style") != 0) log_backend = LOG_BACKEND_JOURNAL; else log_backend = LOG_BACKEND_JOURNAL_SYSLOG_STYLE; |