virlog: Introduce virLogDefineOutputs

Prepare a method that only defines a set of outputs. It takes a list of
outputs, preferably created by virLogParseOutputs. The original set of outputs
is reset and replaced by the new user-provided set of outputs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Erik Skultety 2016-03-17 15:18:06 +01:00
parent b5004b09f5
commit d9d6b61f6d
3 changed files with 28 additions and 0 deletions

View File

@ -1871,6 +1871,7 @@ virLockSpaceReleaseResourcesForOwner;
# util/virlog.h # util/virlog.h
virLogDefineFilter; virLogDefineFilter;
virLogDefineOutput; virLogDefineOutput;
virLogDefineOutputs;
virLogFilterFree; virLogFilterFree;
virLogFilterListFree; virLogFilterListFree;
virLogFilterNew; virLogFilterNew;

View File

@ -1681,3 +1681,28 @@ virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
return -1; return -1;
} }
/**
* virLogDefineOutputs:
* @outputs: new set of outputs to be defined
* @noutputs: number of outputs in @outputs
*
* Resets any existing set of outputs and defines a completely new one.
*
* Returns number of outputs successfully defined or -1 in case of error;
*/
int
virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
{
if (virLogInitialize() < 0)
return -1;
virLogLock();
virLogResetOutputs();
virLogOutputs = outputs;
virLogNbOutputs = noutputs;
virLogUnlock();
return 0;
}

View File

@ -237,5 +237,7 @@ virLogFilterPtr virLogFilterNew(const char *match,
unsigned int flags) ATTRIBUTE_NONNULL(1); unsigned int flags) ATTRIBUTE_NONNULL(1);
int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs, int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
virLogDestination dest, const void *opaque); virLogDestination dest, const void *opaque);
int virLogDefineOutputs(virLogOutputPtr *outputs,
size_t noutputs) ATTRIBUTE_NONNULL(1);
#endif #endif