Along with an empty string, it should also be possible for users to pass NULL
to the public APIs which in turn would trigger a routine (future work)
responsible for defining an appropriate default logging output given the current
circumstances.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
daemon/libvirtd.c | 2 +-
src/locking/lock_daemon.c | 2 +-
src/logging/log_daemon.c | 2 +-
src/util/virlog.c | 8 +++++++-
src/util/virlog.h | 2 +-
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index cd25b50..3902a8b 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -693,7 +693,7 @@ daemonSetupLogging(struct daemonConfig *config,
if (virLogGetNbFilters() == 0)
virLogSetFilters(config->log_filters);
- if (config->log_outputs && virLogGetNbOutputs() == 0)
+ if (virLogGetNbOutputs() == 0)
virLogSetOutputs(config->log_outputs);
/*
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 02745be..9ee818e 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -478,7 +478,7 @@ virLockDaemonSetupLogging(virLockDaemonConfigPtr config,
if (virLogGetNbFilters() == 0)
virLogSetFilters(config->log_filters);
- if (config->log_outputs && virLogGetNbOutputs() == 0)
+ if (virLogGetNbOutputs() == 0)
virLogSetOutputs(config->log_outputs);
/*
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 04bb836..a9aebdb 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -406,7 +406,7 @@ virLogDaemonSetupLogging(virLogDaemonConfigPtr config,
if (virLogGetNbFilters() == 0)
virLogSetFilters(config->log_filters);
- if (config->log_outputs && virLogGetNbOutputs() == 0)
+ if (virLogGetNbOutputs() == 0)
virLogSetOutputs(config->log_outputs);
/*
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 9b52e66..acd2285 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1818,6 +1818,8 @@ virLogParseFilters(const char *src, virLogFilterPtr **filters)
* @outputs: string defining a (set of) output(s)
*
* Replaces the current set of defined outputs with a new set of outputs.
+ * Should the set be empty or NULL, a default output is used according to the
+ * daemon's runtime attributes.
*
* Returns 0 on success or -1 in case of an error.
*/
@@ -1826,12 +1828,16 @@ virLogSetOutputs(const char *src)
{
int ret = -1;
int noutputs = 0;
+ const char *outputstr = virLogDefaultOutput;
virLogOutputPtr *outputs = NULL;
if (virLogInitialize() < 0)
return -1;
- if ((noutputs = virLogParseOutputs(src, &outputs)) < 0)
+ if (src && *src)
+ outputstr = src;
+
+ if ((noutputs = virLogParseOutputs(outputstr, &outputs)) < 0)
goto cleanup;
if (virLogDefineOutputs(outputs, noutputs) < 0)
diff --git a/src/util/virlog.h b/src/util/virlog.h
index b4ffeca..cc09f48 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -187,7 +187,7 @@ void virLogOutputFree(virLogOutputPtr output);
void virLogOutputListFree(virLogOutputPtr *list, int count);
void virLogFilterFree(virLogFilterPtr filter);
void virLogFilterListFree(virLogFilterPtr *list, int count);
-int virLogSetOutputs(const char *outputs) ATTRIBUTE_NONNULL(1);
+int virLogSetOutputs(const char *outputs);
int virLogSetFilters(const char *filters);
char *virLogGetDefaultOutput(void);
int virLogSetDefaultOutput(const char *fname, bool godaemon, bool privileged);
--
2.5.5