summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-07-08 17:13:59 +0200
committerThomas Haller <thaller@redhat.com>2015-07-12 14:49:04 +0200
commit489650b3ab52899403fdb5f6f0787bdf224de0d4 (patch)
treebb9fe07421c96cebf4d1303a9cd7fad23d9a61a1
parentb741b17792d4f0c38cad58b8c40f798ca00536ac (diff)
downloadNetworkManager-489650b3ab52899403fdb5f6f0787bdf224de0d4.tar.gz
logging: refactor @syslog_opened variable to @log_backend
-rw-r--r--src/nm-logging.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/nm-logging.c b/src/nm-logging.c
index f6936e8243..ac418da193 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -48,7 +48,10 @@ static NMLogLevel log_level = LOGL_INFO;
static char *log_domains;
static NMLogDomain logging[LOGL_MAX];
static gboolean logging_set_up;
-static gboolean syslog_opened;
+enum {
+ LOG_BACKEND_GLIB,
+ LOG_BACKEND_SYSLOG,
+} log_backend = LOG_BACKEND_GLIB;
static char *logging_domains_to_string;
typedef struct {
@@ -426,10 +429,13 @@ _nm_log_impl (const char *file,
g_assert_not_reached ();
}
- if (syslog_opened)
+ switch (log_backend) {
+ case LOG_BACKEND_SYSLOG:
syslog (syslog_level, "%s", fullmsg);
- else
+ break;
+ default:
g_log (G_LOG_DOMAIN, g_log_level, "%s", fullmsg);
+ }
g_free (msg);
g_free (fullmsg);
@@ -473,9 +479,10 @@ nm_log_handler (const gchar *log_domain,
void
nm_logging_syslog_openlog (gboolean debug)
{
- if (syslog_opened)
+ if (log_backend != LOG_BACKEND_GLIB)
g_return_if_reached ();
- syslog_opened = TRUE;
+
+ log_backend = LOG_BACKEND_SYSLOG;
if (debug)
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);