LogInit: use struct ConfigData

This commit is contained in:
Max Kellermann 2018-07-17 23:02:06 +02:00
parent a9b8d5ecb6
commit 0b4e0b7bcb
3 changed files with 8 additions and 6 deletions

View File

@ -22,7 +22,7 @@
#include "LogBackend.hxx" #include "LogBackend.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "config/Param.hxx" #include "config/Param.hxx"
#include "config/Global.hxx" #include "config/Data.hxx"
#include "config/Option.hxx" #include "config/Option.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "fs/FileSystem.hxx" #include "fs/FileSystem.hxx"
@ -118,7 +118,7 @@ log_early_init(bool verbose)
} }
void void
log_init(bool verbose, bool use_stdout) log_init(const ConfigData &config, bool verbose, bool use_stdout)
{ {
#ifdef ANDROID #ifdef ANDROID
(void)verbose; (void)verbose;
@ -126,14 +126,14 @@ log_init(bool verbose, bool use_stdout)
#else #else
if (verbose) if (verbose)
SetLogThreshold(LogLevel::DEBUG); SetLogThreshold(LogLevel::DEBUG);
else if (const auto &param = config_get_param(ConfigOption::LOG_LEVEL)) else if (const auto &param = config.GetParam(ConfigOption::LOG_LEVEL))
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; out_fd = STDOUT_FILENO;
} else { } else {
const auto *param = config_get_param(ConfigOption::LOG_FILE); const auto *param = config.GetParam(ConfigOption::LOG_FILE);
if (param == nullptr) { if (param == nullptr) {
/* no configuration: default to syslog (if /* no configuration: default to syslog (if
available) */ available) */

View File

@ -20,6 +20,8 @@
#ifndef MPD_LOG_INIT_HXX #ifndef MPD_LOG_INIT_HXX
#define MPD_LOG_INIT_HXX #define MPD_LOG_INIT_HXX
struct ConfigData;
/** /**
* Configure a logging destination for daemon startup, before the * Configure a logging destination for daemon startup, before the
* configuration file is read. This allows the daemon to use the * configuration file is read. This allows the daemon to use the
@ -35,7 +37,7 @@ log_early_init(bool verbose);
* Throws #std::runtime_error on error. * Throws #std::runtime_error on error.
*/ */
void void
log_init(bool verbose, bool use_stdout); log_init(const ConfigData &config, bool verbose, bool use_stdout);
void void
log_deinit(); log_deinit();

View File

@ -509,7 +509,7 @@ try {
TagLoadConfig(raw_config); TagLoadConfig(raw_config);
log_init(options.verbose, options.log_stderr); log_init(raw_config, options.verbose, options.log_stderr);
instance = new Instance(); instance = new Instance();