summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-05-23 12:02:31 +0200
committerThomas Haller <thaller@redhat.com>2016-05-24 19:39:30 +0200
commita0130e412837096fb57b4b1bad90374fcf5d2f52 (patch)
tree52eb12880ea545b518fd70cbdef1bcd542c98688
parent13101f8444863c0ae3639658c9c3f35e9487d8dd (diff)
downloadNetworkManager-a0130e412837096fb57b4b1bad90374fcf5d2f52.tar.gz
logging: add nm_logging_syslog_enabled() function
We want to know, whether running in debug-mode (logging to stdout) or whether we log to syslog.
-rw-r--r--src/nm-logging.c9
-rw-r--r--src/nm-logging.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c
index e517d8d4c6..3f924236e3 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -108,6 +108,7 @@ NMLogDomain _nm_logging_enabled_state[_LOGL_N_REAL] = {
static struct {
NMLogLevel log_level;
LogFormatFlags log_format_flags;
+ bool uses_syslog:1;
enum {
LOG_BACKEND_GLIB,
LOG_BACKEND_SYSLOG,
@@ -737,6 +738,12 @@ nm_log_handler (const gchar *log_domain,
}
}
+gboolean
+nm_logging_syslog_enabled (void)
+{
+ return global.uses_syslog;
+}
+
void
nm_logging_syslog_openlog (const char *logging_backend)
{
@@ -756,6 +763,7 @@ nm_logging_syslog_openlog (const char *logging_backend)
#if SYSTEMD_JOURNAL
} else if (strcmp (logging_backend, "syslog") != 0) {
global.log_backend = LOG_BACKEND_JOURNAL;
+ global.uses_syslog = TRUE;
/* ensure we read a monotonic timestamp. Reading the timestamp the first
* time causes a logging message. We don't want to do that during _nm_log_impl. */
@@ -763,6 +771,7 @@ nm_logging_syslog_openlog (const char *logging_backend)
#endif
} else {
global.log_backend = LOG_BACKEND_SYSLOG;
+ global.uses_syslog = TRUE;
openlog (G_LOG_DOMAIN, LOG_PID, LOG_DAEMON);
}
diff --git a/src/nm-logging.h b/src/nm-logging.h
index 329b457caf..fe478a50f6 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -178,6 +178,7 @@ gboolean nm_logging_setup (const char *level,
char **bad_domains,
GError **error);
void nm_logging_syslog_openlog (const char *logging_backend);
+gboolean nm_logging_syslog_enabled (void);
/*****************************************************************************/