summaryrefslogtreecommitdiff
path: root/src/LogInit.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-29 21:45:58 +0200
committerMax Kellermann <max@musicpd.org>2019-05-29 21:50:04 +0200
commitfdbec694c61f4680ee808460e0122517e4b3a568 (patch)
treed6a119e807ea44fc4dc048dd94178287a70dd691 /src/LogInit.cxx
parentb86d8d0cd83c0646fb31013442579c5d4c26ceb8 (diff)
config/Param: add method With()
Diffstat (limited to 'src/LogInit.cxx')
-rw-r--r--src/LogInit.cxx14
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 &param = 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;