[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 07/12] Split priority conversion from virLogOutputToSyslog



No change in functionality; the newly separated virLogPrioritySyslog
function will be used by the next patch.

Signed-off-by: Miloslav Trmač <mitr redhat com>
---
 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 5471552..b71eacc 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -866,6 +866,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,
@@ -876,27 +892,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;
-- 
1.7.11.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]