mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
virlog: Introduce virLogParseFilters
Abstraction added over parsing a single filter. The method parses potentially a set of logging filters, while adding each filter logging object to a caller-provided array. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
4b266c180b
commit
09d7ced8ee
@ -1891,6 +1891,7 @@ virLogParseAndDefineFilters;
|
|||||||
virLogParseAndDefineOutputs;
|
virLogParseAndDefineOutputs;
|
||||||
virLogParseDefaultPriority;
|
virLogParseDefaultPriority;
|
||||||
virLogParseFilter;
|
virLogParseFilter;
|
||||||
|
virLogParseFilters;
|
||||||
virLogParseOutput;
|
virLogParseOutput;
|
||||||
virLogParseOutputs;
|
virLogParseOutputs;
|
||||||
virLogPriorityFromSyslog;
|
virLogPriorityFromSyslog;
|
||||||
|
@ -2099,3 +2099,53 @@ virLogParseOutputs(const char *src, virLogOutputPtr **outputs)
|
|||||||
virStringFreeList(strings);
|
virStringFreeList(strings);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virLogParseFilters:
|
||||||
|
* @src: string defining a (set of) filter(s)
|
||||||
|
* @filters: pointer to a list where the individual filters shall be parsed
|
||||||
|
*
|
||||||
|
* This method parses @src and produces a list of individual filters which then
|
||||||
|
* needs to be passed to virLogDefineFilters in order to be set and taken into
|
||||||
|
* effect.
|
||||||
|
* Multiple filters can be defined in a single @src, they just need to be
|
||||||
|
* separated by spaces.
|
||||||
|
*
|
||||||
|
* Returns the number of filter parsed or -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virLogParseFilters(const char *src, virLogFilterPtr **filters)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
size_t nfilters = 0;
|
||||||
|
size_t i, count;
|
||||||
|
char **strings = NULL;
|
||||||
|
virLogFilterPtr filter = NULL;
|
||||||
|
virLogFilterPtr *list = NULL;
|
||||||
|
|
||||||
|
VIR_DEBUG("filters=%s", src);
|
||||||
|
|
||||||
|
if (!(strings = virStringSplitCount(src, " ", 0, &count)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
/* virStringSplit may return empty strings */
|
||||||
|
if (STREQ(strings[i], ""))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!(filter = virLogParseFilter(strings[i])))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (VIR_APPEND_ELEMENT(list, nfilters, filter)) {
|
||||||
|
virLogFilterFree(filter);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = nfilters;
|
||||||
|
*filters = list;
|
||||||
|
list = NULL;
|
||||||
|
cleanup:
|
||||||
|
virStringFreeList(strings);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -244,5 +244,7 @@ virLogOutputPtr virLogParseOutput(const char *src) ATTRIBUTE_NONNULL(1);
|
|||||||
virLogFilterPtr virLogParseFilter(const char *src) ATTRIBUTE_NONNULL(1);
|
virLogFilterPtr virLogParseFilter(const char *src) ATTRIBUTE_NONNULL(1);
|
||||||
int virLogParseOutputs(const char *src,
|
int virLogParseOutputs(const char *src,
|
||||||
virLogOutputPtr **outputs) ATTRIBUTE_NONNULL(1);
|
virLogOutputPtr **outputs) ATTRIBUTE_NONNULL(1);
|
||||||
|
int virLogParseFilters(const char *src,
|
||||||
|
virLogFilterPtr **filters) ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user