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