[pulseaudio-commits] 3 commits - src/pulsecore

Tanu Kaskinen tanuk at kemper.freedesktop.org
Mon Jul 15 07:07:26 PDT 2013


 src/pulsecore/log.c |   28 ++++++++++++++++------------
 src/pulsecore/log.h |    4 ----
 2 files changed, 16 insertions(+), 16 deletions(-)

New commits:
commit b5e1c06a5edd24db9ef905ecfb2849630b6527af
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date:   Thu Jun 20 17:24:28 2013 +0300

    log: Harmonize log target output
    
    The file targets used different output format than stderr and syslog.
    That's now fixed.

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:

commit a1fdbcfaa77822bbfdcacb480fc2d75b95fa38aa
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date:   Thu Jun 20 17:24:27 2013 +0300

    log: Use pa_write() instead of write()

diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index 3e1a881..49f1b5b 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -77,6 +77,7 @@ static unsigned show_backtrace = 0, show_backtrace_override = 0, skip_backtrace
 static pa_log_flags_t flags = 0, flags_override = 0;
 static bool no_rate_limit = false;
 static int log_fd = -1;
+static int write_type = 0;
 
 #ifdef HAVE_SYSLOG_H
 static const int level_to_syslog[] = {
@@ -470,7 +471,7 @@ void pa_log_levelv_meta(
 
                     pa_snprintf(metadata, sizeof(metadata), "\n%c %s %s", level_to_char[level], timestamp, location);
 
-                    if ((write(log_fd, metadata, strlen(metadata)) < 0) || (write(log_fd, t, strlen(t)) < 0)) {
+                    if ((pa_write(log_fd, metadata, strlen(metadata), &write_type) < 0) || (pa_write(log_fd, t, strlen(t), &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.");

commit bc2ed3482a3917584a784d7a966e283b5458c176
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date:   Thu Jun 20 17:24:26 2013 +0300

    log: Remove pa_log_set_fd()
    
    The function isn't used any more.

diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index e4f1c30..3e1a881 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -190,15 +190,6 @@ void pa_log_set_flags(pa_log_flags_t _flags, pa_log_merge_t merge) {
         flags = _flags;
 }
 
-void pa_log_set_fd(int fd) {
-    if (fd >= 0)
-        log_fd = fd;
-    else if (log_fd >= 0) {
-        pa_close(log_fd);
-        log_fd = -1;
-    }
-}
-
 void pa_log_set_show_backtrace(unsigned nlevels) {
     show_backtrace = nlevels;
 }
@@ -482,7 +473,6 @@ void pa_log_levelv_meta(
                     if ((write(log_fd, metadata, strlen(metadata)) < 0) || (write(log_fd, t, strlen(t)) < 0)) {
                         pa_log_target new_target = { .type = PA_LOG_STDERR, .file = NULL };
                         saved_errno = errno;
-                        pa_log_set_fd(-1);
                         fprintf(stderr, "%s\n", "Error writing logs to a file descriptor. Redirect log messages to console.");
                         fprintf(stderr, "%s %s\n", metadata, t);
                         pa_log_set_target(&new_target);
diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
index 0cfa0ed..e7dca88 100644
--- a/src/pulsecore/log.h
+++ b/src/pulsecore/log.h
@@ -80,10 +80,6 @@ void pa_log_set_level(pa_log_level_t l);
 /* Set flags */
 void pa_log_set_flags(pa_log_flags_t flags, pa_log_merge_t merge);
 
-/* Set the file descriptor of the logging device.
-   Daemon conf is in charge of opening this device */
-void pa_log_set_fd(int fd);
-
 /* Enable backtrace */
 void pa_log_set_show_backtrace(unsigned nlevels);
 



More information about the pulseaudio-commits mailing list