diff options
author | Max Kellermann <max@duempel.org> | 2008-12-28 19:48:53 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-12-28 19:48:53 +0100 |
commit | caf47f7893a666a9ea289f2ffdbce528d4ba75bd (patch) | |
tree | bf1dd59a46de95d3e7024c22ca91458b439b2d8a | |
parent | 5d2c59e3f11d10f5c5ed6a4c357a7e51fc5de76e (diff) | |
download | mpd-caf47f7893a666a9ea289f2ffdbce528d4ba75bd.tar.gz mpd-caf47f7893a666a9ea289f2ffdbce528d4ba75bd.tar.xz mpd-caf47f7893a666a9ea289f2ffdbce528d4ba75bd.zip |
log: moved code to parse_log_level()
-rw-r--r-- | src/log.c | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -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) |