[PATCH v2 13/20] virlog: Introduce virLogSetOutputs

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

 



This API is the entry point to output modification of the logger. Currently,
everything is done by virLogParseAndDefineOutputs. Parsing and defining will be
split into two operations both handled by this method transparently.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virlog.c        | 31 +++++++++++++++++++++++++++++++
 src/util/virlog.h        |  1 +
 3 files changed, 33 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 063fe5f..5fb30e6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1876,6 +1876,7 @@ virLogProbablyLogMessage;
 virLogReset;
 virLogSetDefaultPriority;
 virLogSetFromEnv;
+virLogSetOutputs;
 virLogUnlock;
 virLogVMessage;
 
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 4b2aa4d..a60c027 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -2110,3 +2110,34 @@ virLogParseFilters(const char *src, virLogFilterPtr **filters)
     virStringFreeList(strings);
     return ret;
 }
+
+/**
+ * virLogSetOutputs:
+ * @outputs: string defining a (set of) output(s)
+ *
+ * Replaces the current set of defined outputs with a new set of outputs.
+ *
+ * Returns the number of outputs successfully defined or -1 in case of an
+ * error.
+ */
+int
+virLogSetOutputs(const char *src)
+{
+    int ret = -1;
+    int noutputs = 0;
+    virLogOutputPtr *outputs = NULL;
+
+    if (virLogInitialize() < 0)
+        return -1;
+
+    if ((noutputs = virLogParseOutputs(src, &outputs)) < 0)
+        goto cleanup;
+
+    if ((ret = virLogDefineOutputs(outputs, noutputs)) < 0)
+        goto cleanup;
+
+ cleanup:
+    if (ret < 0)
+        virLogOutputListFree(outputs, noutputs);
+    return ret;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 9ccc650..88e6ac8 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -197,6 +197,7 @@ void virLogOutputFree(virLogOutputPtr output);
 void virLogOutputListFree(virLogOutputPtr *list, int count);
 void virLogFilterFree(virLogFilterPtr filter);
 void virLogFilterListFree(virLogFilterPtr *list, int count);
+int virLogSetOutputs(const char *outputs);
 
 /*
 * Internal logging API
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]