From 3016c7561d1efb322fae6c82932970c89659ad54 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 14 Feb 2007 09:26:48 +0000 Subject: [PATCH] Prefix log lines with a character indicating level. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1427 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/log.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index 7eb83de..d8a9efe 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -129,6 +129,7 @@ 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 @@ -144,11 +145,33 @@ 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\n", location, prefix, t, suffix); - else { - fprintf(stderr, "%s%s%s%s\n", location, prefix, local_t, suffix); + 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); pa_xfree(local_t); } -- 2.7.4