aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-28 19:48:53 +0100
committerMax Kellermann <max@duempel.org>2008-12-28 19:48:53 +0100
commitcaf47f7893a666a9ea289f2ffdbce528d4ba75bd (patch)
treebf1dd59a46de95d3e7024c22ca91458b439b2d8a /src
parent5d2c59e3f11d10f5c5ed6a4c357a7e51fc5de76e (diff)
downloadmpd-caf47f7893a666a9ea289f2ffdbce528d4ba75bd.tar.gz
mpd-caf47f7893a666a9ea289f2ffdbce528d4ba75bd.tar.xz
mpd-caf47f7893a666a9ea289f2ffdbce528d4ba75bd.zip
log: moved code to parse_log_level()
Diffstat (limited to 'src')
-rw-r--r--src/log.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/log.c b/src/log.c
index 76293decf..b3f8410ee 100644
--- a/src/log.c
+++ b/src/log.c
@@ -101,6 +101,20 @@ open_log_file(void)
return open(out_filename, O_CREAT | O_WRONLY | O_APPEND, 0666);
}
+static inline GLogLevelFlags
+parse_log_level(const char *value, unsigned line)
+{
+ if (0 == strcmp(value, "default"))
+ return G_LOG_LEVEL_MESSAGE;
+ if (0 == strcmp(value, "secure"))
+ return LOG_LEVEL_SECURE;
+ else if (0 == strcmp(value, "verbose"))
+ return G_LOG_LEVEL_DEBUG;
+ else
+ FATAL("unknown log level \"%s\" at line %u\n",
+ value, line);
+}
+
void initLog(bool verbose)
{
ConfigParam *param;
@@ -109,22 +123,10 @@ void initLog(bool verbose)
g_log_set_default_handler(mpd_log_func, NULL);
- if (verbose) {
- log_threshold = G_LOG_LEVEL_DEBUG;
- return;
- }
- if (!(param = getConfigParam(CONF_LOG_LEVEL)))
- return;
- if (0 == strcmp(param->value, "default")) {
- log_threshold = G_LOG_LEVEL_MESSAGE;
- } else if (0 == strcmp(param->value, "secure")) {
- log_threshold = LOG_LEVEL_SECURE;
- } else if (0 == strcmp(param->value, "verbose")) {
+ if (verbose)
log_threshold = G_LOG_LEVEL_DEBUG;
- } else {
- FATAL("unknown log level \"%s\" at line %i\n",
- param->value, param->line);
- }
+ else if ((param = getConfigParam(CONF_LOG_LEVEL)) != NULL)
+ log_threshold = parse_log_level(param->value, param->line);
}
void open_log_files(bool use_stdout)