1
0

util: Do not hide errors in virLogSetDefaultOutput

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Martin Kletzander 2021-12-15 16:37:39 +01:00
parent 3e54152d9f
commit 47fb83f8b7
2 changed files with 6 additions and 4 deletions

View File

@ -201,7 +201,7 @@ virLogSetDefaultOutputToFile(const char *binary, bool privileged)
* according to @binary, @godaemon, @privileged. This function should be run * according to @binary, @godaemon, @privileged. This function should be run
* exactly once at daemon startup, so no locks are used. * exactly once at daemon startup, so no locks are used.
*/ */
void int
virLogSetDefaultOutput(const char *binary, bool godaemon, bool privileged) virLogSetDefaultOutput(const char *binary, bool godaemon, bool privileged)
{ {
bool have_journald = access("/run/systemd/journal/socket", W_OK) >= 0; bool have_journald = access("/run/systemd/journal/socket", W_OK) >= 0;
@ -209,14 +209,16 @@ virLogSetDefaultOutput(const char *binary, bool godaemon, bool privileged)
if (godaemon) { if (godaemon) {
if (have_journald) if (have_journald)
virLogSetDefaultOutputToJournald(); virLogSetDefaultOutputToJournald();
else else if (virLogSetDefaultOutputToFile(binary, privileged) < 0)
virLogSetDefaultOutputToFile(binary, privileged); return -1;
} else { } else {
if (!isatty(STDIN_FILENO) && have_journald) if (!isatty(STDIN_FILENO) && have_journald)
virLogSetDefaultOutputToJournald(); virLogSetDefaultOutputToJournald();
else else
virLogSetDefaultOutputToStderr(); virLogSetDefaultOutputToStderr();
} }
return 0;
} }

View File

@ -154,7 +154,7 @@ void virLogFilterListFree(virLogFilter **list, int count);
int virLogSetOutputs(const char *outputs); int virLogSetOutputs(const char *outputs);
int virLogSetFilters(const char *filters); int virLogSetFilters(const char *filters);
char *virLogGetDefaultOutput(void); char *virLogGetDefaultOutput(void);
void virLogSetDefaultOutput(const char *fname, bool godaemon, bool privileged); int virLogSetDefaultOutput(const char *fname, bool godaemon, bool privileged);
/* /*
* Internal logging API * Internal logging API