virlog: Introduce virLogSetFilters

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Erik Skultety 2016-03-24 14:34:11 +01:00
parent 6db7b8cbb5
commit c33babfe31
3 changed files with 34 additions and 0 deletions

View File

@ -1898,6 +1898,7 @@ virLogPriorityFromSyslog;
virLogProbablyLogMessage; virLogProbablyLogMessage;
virLogReset; virLogReset;
virLogSetDefaultPriority; virLogSetDefaultPriority;
virLogSetFilters;
virLogSetFromEnv; virLogSetFromEnv;
virLogSetOutputs; virLogSetOutputs;
virLogUnlock; virLogUnlock;

View File

@ -2180,3 +2180,35 @@ virLogSetOutputs(const char *src)
virLogOutputListFree(outputs, noutputs); virLogOutputListFree(outputs, noutputs);
return ret; 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 0 on success 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 (src && (nfilters = virLogParseFilters(src, &filters)) < 0)
goto cleanup;
if (virLogDefineFilters(filters, nfilters) < 0)
goto cleanup;
filters = NULL;
ret = 0;
cleanup:
virLogFilterListFree(filters, nfilters);
return ret;
}

View File

@ -198,6 +198,7 @@ void virLogOutputListFree(virLogOutputPtr *list, int count);
void virLogFilterFree(virLogFilterPtr filter); void virLogFilterFree(virLogFilterPtr filter);
void virLogFilterListFree(virLogFilterPtr *list, int count); void virLogFilterListFree(virLogFilterPtr *list, int count);
int virLogSetOutputs(const char *outputs) ATTRIBUTE_NONNULL(1); int virLogSetOutputs(const char *outputs) ATTRIBUTE_NONNULL(1);
int virLogSetFilters(const char *filters);
/* /*
* Internal logging API * Internal logging API