diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-05-27 16:37:05 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-05-27 16:37:05 +0000 |
commit | 872018efc855e8ea7f3277d1e08c855c63c96897 (patch) | |
tree | 107de2249d415291ce85175727c7ff1c7e4c87b7 /src/pulsecore/log.c | |
parent | d949983845cdc514aebe08cf43cfc13c49495ea8 (diff) |
Minor optimization: read log level character code from array
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1457 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/log.c')
-rw-r--r-- | src/pulsecore/log.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index d8a9efe9..0033adb9 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -62,6 +62,14 @@ static const int level_to_syslog[] = { }; #endif +static const char level_to_char[] = { + [PA_LOG_ERROR] = 'E', + [PA_LOG_WARN] = 'W', + [PA_LOG_NOTICE] = 'N', + [PA_LOG_INFO] = 'I', + [PA_LOG_DEBUG] = 'D' +}; + void pa_log_set_ident(const char *p) { if (log_ident) pa_xfree(log_ident); @@ -129,7 +137,6 @@ void pa_log_levelv_meta( switch (log_target) { case PA_LOG_STDERR: { const char *prefix = "", *suffix = ""; - const char *level_code = ""; char *local_t; #ifndef OS_IS_WIN32 @@ -145,33 +152,11 @@ void pa_log_levelv_meta( } #endif - switch (level) { - case PA_LOG_ERROR: - level_code = "E"; - break; - case PA_LOG_WARN: - level_code = "W"; - break; - case PA_LOG_NOTICE: - level_code = "N"; - break; - case PA_LOG_INFO: - level_code = "I"; - break; - case PA_LOG_DEBUG: - level_code = "D"; - break; - default: - level_code = "?"; - } - local_t = pa_utf8_to_locale(t); - if (!local_t) { - fprintf(stderr, "%s: %s%s%s%s\n", level_code, location, - prefix, t, suffix); - } else { - fprintf(stderr, "%s: %s%s%s%s\n", level_code, location, - prefix, local_t, suffix); + if (!local_t) + fprintf(stderr, "%c: %s%s%s%s\n", level_to_char[level], location, prefix, t, suffix); + else { + fprintf(stderr, "%c: %s%s%s%s\n", level_to_char[level], location, prefix, local_t, suffix); pa_xfree(local_t); } |