提交 435200ca 编写于 作者: E Erik Skultety

virlog: Introduce virLogFilterNew

This method allocates a new filter object which it then returns back to caller.
Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 b0f5dc91
......@@ -1873,6 +1873,7 @@ virLogDefineFilter;
virLogDefineOutput;
virLogFilterFree;
virLogFilterListFree;
virLogFilterNew;
virLogGetDefaultPriority;
virLogGetFilters;
virLogGetNbFilters;
......
......@@ -1601,3 +1601,51 @@ 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 (priority < VIR_LOG_DEBUG || priority > VIR_LOG_ERROR) {
virReportError(VIR_ERR_INVALID_ARG, _("Invalid log priority %d"),
priority);
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;
}
......@@ -232,5 +232,8 @@ virLogOutputPtr virLogOutputNew(virLogOutputFunc f,
virLogPriority priority,
virLogDestination dest,
const char *name) ATTRIBUTE_NONNULL(1);
virLogFilterPtr virLogFilterNew(const char *match,
virLogPriority priority,
unsigned int flags) ATTRIBUTE_NONNULL(1);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册