[PATCH v2 03/20] virlog: Introduce virLogFilterNew

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

 



This method allocated a new filter object which it then returns back to caller.

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

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b5cee5f..088f9f3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1845,6 +1845,8 @@ virLockSpaceReleaseResourcesForOwner;
 virLogDefineFilter;
 virLogDefineOutput;
 virLogFilterFree;
+virLogFilterListFree;
+virLogFilterNew;
 virLogGetDefaultPriority;
 virLogGetFilters;
 virLogGetNbFilters;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 91c63a1..e4dc84b 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1604,3 +1604,49 @@ virLogOutputNew(virLogOutputFunc f,
 
     return ret;
 }
+
+
+/**
+ * virLogFilterNew:
+ * @match: the pattern to match
+ * @priority: the priority to give to messages matching the pattern
+ * @flags: extra flags, see virLogFilterFlags enum
+ *
+ * Allocates and returns a new log filter object. The object has to be later
+ * defined, so that the pattern will be taken into account when executing the
+ * log filters (to select or reject a particular message) on messages.
+ *
+ * The filter defines a rules that will apply only to messages matching
+ * the pattern (currently if @match is a substring of the message category)
+ *
+ * Returns a reference to a newly created filter that needs to be defined using
+ * virLogDefineFilters, or NULL in case of an error.
+ */
+virLogFilterPtr
+virLogFilterNew(const char *match,
+                virLogPriority priority,
+                unsigned int flags)
+{
+    virLogFilterPtr ret = NULL;
+    char *mdup = NULL;
+
+    virCheckFlags(VIR_LOG_STACK_TRACE, NULL);
+
+    if ((match == NULL) || (priority < VIR_LOG_DEBUG) ||
+        (priority > VIR_LOG_ERROR))
+        return NULL;
+
+    if (VIR_STRDUP_QUIET(mdup, match) < 0)
+        return NULL;
+
+    if (VIR_ALLOC_QUIET(ret) < 0) {
+        VIR_FREE(mdup);
+        return NULL;
+    }
+
+    ret->match = mdup;
+    ret->priority = priority;
+    ret->flags = flags;
+
+    return ret;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index fb32c41..a56d297 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -232,5 +232,8 @@ virLogOutputPtr virLogOutputNew(virLogOutputFunc f,
                                 virLogPriority priority,
                                 virLogDestination dest,
                                 const char *name);
+virLogFilterPtr virLogFilterNew(const char *match,
+                                virLogPriority priority,
+                                unsigned int flags);
 
 #endif
-- 
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]