[PATCH 11/38] virlog: Introduce virLogDefineFilters

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

 



Prepare a method that only defines a set of filters. It takes a list of
filters, preferably created by virLogParseFilters. The original set of filters
is reset and replaced by the new user-provided set of filters.
---
 src/libvirt_private.syms |  1 +
 src/util/virlog.c        | 25 +++++++++++++++++++++++++
 src/util/virlog.h        |  1 +
 3 files changed, 27 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e97ec45..8773270 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1742,6 +1742,7 @@ virLockSpaceReleaseResourcesForOwner;
 
 # util/virlog.h
 virLogDefineFilter;
+virLogDefineFilters;
 virLogDefineOutput;
 virLogDefineOutputs;
 virLogGetDefaultPriority;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index e5923ce..60573a9 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1564,3 +1564,28 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
 
     return virLogNbOutputs;
 }
+
+/**
+ * virLogDefineFilters:
+ * @filters: new set of filters to be defined
+ * @nfilters: number of filters in @filters
+ *
+ * Resets any existing set of filters and defines a completely new one.
+ *
+ * Returns number of filters successfully defined or -1 in case of error;
+ */
+int
+virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters)
+{
+    if (virLogInitialize() < 0)
+        return -1;
+
+    virLogLock();
+    virLogResetOutputs();
+    virLogFilters = filters;
+    virLogNbOutputs = nfilters;
+    virLogFiltersSerial++;
+    virLogUnlock();
+
+    return virLogNbFilters;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 166db5a..ff16034 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -225,5 +225,6 @@ extern void virLogVMessage(virLogSourcePtr source,
 
 bool virLogProbablyLogMessage(const char *str);
 int virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs);
+int virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters);
 
 #endif
-- 
2.4.3

--
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]