diff options
author | Max Kellermann <max@musicpd.org> | 2019-05-29 21:45:58 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-05-29 21:50:04 +0200 |
commit | fdbec694c61f4680ee808460e0122517e4b3a568 (patch) | |
tree | d6a119e807ea44fc4dc048dd94178287a70dd691 /src/LogInit.cxx | |
parent | b86d8d0cd83c0646fb31013442579c5d4c26ceb8 (diff) |
config/Param: add method With()
Diffstat (limited to 'src/LogInit.cxx')
-rw-r--r-- | src/LogInit.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 7154c40d6..66add54e6 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -93,7 +93,7 @@ log_init_file(int line) } static inline LogLevel -parse_log_level(const char *value, int line) +parse_log_level(const char *value) { if (0 == strcmp(value, "default")) return LogLevel::DEFAULT; @@ -102,8 +102,7 @@ parse_log_level(const char *value, int line) else if (0 == strcmp(value, "verbose")) return LogLevel::DEBUG; else - throw FormatRuntimeError("unknown log level \"%s\" at line %d", - value, line); + throw FormatRuntimeError("unknown log level \"%s\"", value); } #endif @@ -132,9 +131,12 @@ log_init(const ConfigData &config, bool verbose, bool use_stdout) #else if (verbose) SetLogThreshold(LogLevel::DEBUG); - else if (const auto ¶m = config.GetParam(ConfigOption::LOG_LEVEL)) - SetLogThreshold(parse_log_level(param->value.c_str(), - param->line)); + else + SetLogThreshold(config.With(ConfigOption::LOG_LEVEL, [](const char *s){ + return s != nullptr + ? parse_log_level(s) + : LogLevel::DEFAULT; + })); if (use_stdout) { out_fd = STDOUT_FILENO; |