LogInit: convert use_stdout flag to out_fd=STDOUT_FILENO
This commit is contained in:
parent
9614c48e4c
commit
5013de6770
|
@ -130,7 +130,9 @@ log_init(bool verbose, bool use_stdout)
|
|||
SetLogThreshold(parse_log_level(param->value.c_str(),
|
||||
param->line));
|
||||
|
||||
if (!use_stdout) {
|
||||
if (use_stdout) {
|
||||
out_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
const auto *param = config_get_param(ConfigOption::LOG_FILE);
|
||||
if (param == nullptr) {
|
||||
/* no configuration: default to syslog (if
|
||||
|
@ -171,12 +173,10 @@ log_deinit(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void setup_log_output(bool use_stdout)
|
||||
void setup_log_output()
|
||||
{
|
||||
#ifdef ANDROID
|
||||
(void)use_stdout;
|
||||
#else
|
||||
if (use_stdout)
|
||||
#ifndef ANDROID
|
||||
if (out_fd == STDOUT_FILENO)
|
||||
return;
|
||||
|
||||
fflush(nullptr);
|
||||
|
|
|
@ -40,7 +40,8 @@ log_init(bool verbose, bool use_stdout);
|
|||
void
|
||||
log_deinit();
|
||||
|
||||
void setup_log_output(bool use_stdout);
|
||||
void
|
||||
setup_log_output();
|
||||
|
||||
int
|
||||
cycle_log_files();
|
||||
|
|
12
src/Main.cxx
12
src/Main.cxx
|
@ -382,7 +382,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
#endif
|
||||
|
||||
static int mpd_main_after_fork(struct options);
|
||||
static int
|
||||
mpd_main_after_fork();
|
||||
|
||||
#ifdef ANDROID
|
||||
static inline
|
||||
|
@ -467,19 +468,20 @@ try {
|
|||
This must be run after forking; if dispatch is called before forking,
|
||||
the child process will have a broken internal dispatch state. */
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
exit(mpd_main_after_fork(options));
|
||||
exit(mpd_main_after_fork());
|
||||
});
|
||||
dispatch_main();
|
||||
return EXIT_FAILURE; // unreachable, because dispatch_main never returns
|
||||
#else
|
||||
return mpd_main_after_fork(options);
|
||||
return mpd_main_after_fork();
|
||||
#endif
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static int mpd_main_after_fork(struct options options)
|
||||
static int
|
||||
mpd_main_after_fork()
|
||||
try {
|
||||
ConfigureFS();
|
||||
|
||||
|
@ -514,7 +516,7 @@ try {
|
|||
#endif
|
||||
|
||||
#ifndef ANDROID
|
||||
setup_log_output(options.log_stderr);
|
||||
setup_log_output();
|
||||
|
||||
SignalHandlersInit(instance->event_loop);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue