[PATCH v2 14/20] virlog: Introduce virLogSetFilters

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

 



This method will eventually replace virLogParseAndDefineFilters which
currently does both parsing and defining.

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 5fb30e6..fec0b8b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1875,6 +1875,7 @@ virLogPriorityFromSyslog;
 virLogProbablyLogMessage;
 virLogReset;
 virLogSetDefaultPriority;
+virLogSetFilters;
 virLogSetFromEnv;
 virLogSetOutputs;
 virLogUnlock;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index a60c027..b1d2543 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -2141,3 +2141,34 @@ virLogSetOutputs(const char *src)
         virLogOutputListFree(outputs, noutputs);
     return ret;
 }
+
+
+/**
+ * virLogSetFilters:
+ * @src: string defining a (set of) filter(s)
+ *
+ * Replaces the current set of defined filters with a new set of filters.
+ *
+ * Returns the number of filters successfully defined or -1 in case of an
+ * error.
+ */
+int
+virLogSetFilters(const char *src)
+{
+    int ret = -1;
+    int nfilters = 0;
+    virLogFilterPtr *filters = NULL;
+
+    if (virLogInitialize() < 0)
+        return -1;
+
+    if ((nfilters = virLogParseFilters(src, &filters)) < 0)
+        goto cleanup;
+
+    if ((ret = virLogDefineFilters(filters, nfilters)) < 0)
+        goto cleanup;
+
+ cleanup:
+    virLogFilterListFree(filters, nfilters);
+    return ret;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 88e6ac8..2f88f2f 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -198,6 +198,7 @@ void virLogOutputListFree(virLogOutputPtr *list, int count);
 void virLogFilterFree(virLogFilterPtr filter);
 void virLogFilterListFree(virLogFilterPtr *list, int count);
 int virLogSetOutputs(const char *outputs);
+int virLogSetFilters(const char *filters);
 
 /*
 * 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]