LogInit: default to journal if MPD was started as systemd service
This commit is contained in:
parent
94c31d0da9
commit
8682183bc3
1
NEWS
1
NEWS
@ -2,6 +2,7 @@ ver 0.21.3 (not yet released)
|
||||
* output
|
||||
- alsa: fix crash bug
|
||||
- alsa: fix stuttering at start of playback
|
||||
* log: default to journal if MPD was started as systemd service
|
||||
|
||||
ver 0.21.2 (2018/11/12)
|
||||
* protocol
|
||||
|
@ -30,6 +30,10 @@
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "system/Error.hxx"
|
||||
|
||||
#ifdef ENABLE_SYSTEMD_DAEMON
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@ -139,6 +143,16 @@ log_init(const ConfigData &config, bool verbose, bool use_stdout)
|
||||
if (param == nullptr) {
|
||||
/* no configuration: default to syslog (if
|
||||
available) */
|
||||
#ifdef ENABLE_SYSTEMD_DAEMON
|
||||
if (sd_booted() &&
|
||||
getenv("NOTIFY_SOCKET") != nullptr) {
|
||||
/* if MPD was started as a systemd
|
||||
service, default to journal (which
|
||||
is connected to fd=2) */
|
||||
out_fd = STDOUT_FILENO;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#ifndef HAVE_SYSLOG
|
||||
throw std::runtime_error("config parameter 'log_file' not found");
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user