From b5e1c06a5edd24db9ef905ecfb2849630b6527af Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Thu, 20 Jun 2013 17:24:28 +0300 Subject: [PATCH] log: Harmonize log target output The file targets used different output format than stderr and syslog. That's now fixed. --- src/pulsecore/log.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index 49f1b5b..a25a760 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -466,12 +466,23 @@ void pa_log_levelv_meta( case PA_LOG_FILE: case PA_LOG_NEWFILE: { + char *local_t; + + if ((local_t = pa_utf8_to_locale(t))) + t = local_t; + if (log_fd >= 0) { char metadata[256]; - pa_snprintf(metadata, sizeof(metadata), "\n%c %s %s", level_to_char[level], timestamp, location); + if (_flags & PA_LOG_PRINT_LEVEL) + pa_snprintf(metadata, sizeof(metadata), "%s%c: %s", timestamp, level_to_char[level], location); + else + pa_snprintf(metadata, sizeof(metadata), "%s%s", timestamp, location); - if ((pa_write(log_fd, metadata, strlen(metadata), &write_type) < 0) || (pa_write(log_fd, t, strlen(t), &write_type) < 0)) { + if ((pa_write(log_fd, metadata, strlen(metadata), &write_type) < 0) + || (pa_write(log_fd, t, strlen(t), &write_type) < 0) + || (bt && pa_write(log_fd, bt, strlen(bt), &write_type) < 0) + || (pa_write(log_fd, "\n", 1, &write_type) < 0)) { pa_log_target new_target = { .type = PA_LOG_STDERR, .file = NULL }; saved_errno = errno; fprintf(stderr, "%s\n", "Error writing logs to a file descriptor. Redirect log messages to console."); @@ -480,6 +491,8 @@ void pa_log_levelv_meta( } } + pa_xfree(local_t); + break; } case PA_LOG_NULL: -- 2.7.4