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-14 15:52:50 +0200
commit831a5e32fb38ec0407b986bee0984142bffbdac8 (patch)
tree86f05fd259ea35e6a6f0953a4b6df0c33f336189
parentd0345ede266fa361e07bbd337be33517ede442c5 (diff)
downloadNetworkManager-831a5e32fb38ec0407b986bee0984142bffbdac8.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);