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.
---
src/libvirt_private.syms | 1 +
src/util/virlog.c | 25 +++++++++++++++++++++++++
src/util/virlog.h | 1 +
3 files changed, 27 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dafcb6c..565fc7c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1786,6 +1786,7 @@ virLockSpaceReleaseResourcesForOwner;
# util/virlog.h
virLogDefineFilter;
virLogDefineOutput;
+virLogDefineOutputs;
virLogGetDefaultPriority;
virLogGetFilters;
virLogGetNbFilters;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 9059722..e5923ce 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1539,3 +1539,28 @@ virLogSetOutputs(const char *outputs)
return ret;
}
+
+
+/**
+ * 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 virLogNbOutputs;
+}
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 4141ecd..166db5a 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -224,5 +224,6 @@ extern void virLogVMessage(virLogSourcePtr source,
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0);
bool virLogProbablyLogMessage(const char *str);
+int virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs);
#endif
--
2.4.11