1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

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
* exactly once at daemon startup, so no locks are used.
*/
void
int
virLogSetDefaultOutput(const char *binary, bool godaemon, bool privileged)
{
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 (have_journald)
virLogSetDefaultOutputToJournald();
else
virLogSetDefaultOutputToFile(binary, privileged);
else if (virLogSetDefaultOutputToFile(binary, privileged) < 0)
return -1;
} else {
if (!isatty(STDIN_FILENO) && have_journald)
virLogSetDefaultOutputToJournald();
else
virLogSetDefaultOutputToStderr();
}
return 0;
}

View File

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