From ac707017e74c6300baf32e5254fa78f59679f782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Thu, 27 Sep 2012 12:34:04 +0100 Subject: [PATCH] Split priority conversion from virLogOutputToSyslog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow for the code converting from libvirt log levels to syslog log levels to be reused. Signed-off-by: Miloslav Trmač Signed-off-by: Daniel P. Berrange --- src/util/logging.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/util/logging.c b/src/util/logging.c index cdaf86ebfc..dc78e948d8 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -862,6 +862,22 @@ static int virLogAddOutputToFile(int priority, const char *file) { } #if HAVE_SYSLOG_H +static int virLogPrioritySyslog(virLogPriority priority) +{ + switch (priority) { + case VIR_LOG_DEBUG: + return LOG_DEBUG; + case VIR_LOG_INFO: + return LOG_INFO; + case VIR_LOG_WARN: + return LOG_WARNING; + case VIR_LOG_ERROR: + return LOG_ERR; + default: + return LOG_ERR; + } +} + static void virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED, int priority, const char *funcname ATTRIBUTE_UNUSED, @@ -871,27 +887,9 @@ static void virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED, const char *str, void *data ATTRIBUTE_UNUSED) { - int prio; - virCheckFlags(VIR_LOG_STACK_TRACE,); - switch (priority) { - case VIR_LOG_DEBUG: - prio = LOG_DEBUG; - break; - case VIR_LOG_INFO: - prio = LOG_INFO; - break; - case VIR_LOG_WARN: - prio = LOG_WARNING; - break; - case VIR_LOG_ERROR: - prio = LOG_ERR; - break; - default: - prio = LOG_ERR; - } - syslog(prio, "%s", str); + syslog(virLogPrioritySyslog(priority), "%s", str); } static char *current_ident = NULL; -- GitLab