[pulseaudio-commits] Branch 'next' - 2 commits - src/pulse src/pulsecore

Tanu Kaskinen tanuk at kemper.freedesktop.org
Mon Aug 17 05:49:33 PDT 2015


 src/pulse/pulseaudio.h |   41 +++++++++++++++++++++++++++++++++++++++++
 src/pulsecore/log.c    |    7 +++++++
 2 files changed, 48 insertions(+)

New commits:
commit 262bdae0330e1c6832197f3f449e82fe3e1378b5
Author: Ahmed S. Darwish <darwish.07 at gmail.com>
Date:   Fri Aug 14 18:47:32 2015 +0200

    log: Introduce PULSE_LOG_JOURNAL environment variable
    
    By introducing such an environment variable, applications using the
    PA client libraries can configure these libraries to send their logs
    directly to the journal.
    
    While client libraries journal logging can be indirectly achieved
    using PULSE_LOG_SYSLOG, this pollutes the journal. Meta data gets
    replicated twice: once in the journal meta fields and once in the
    syslog(3) plain-text message itself.
    
    For attaching any backtraces, also introduce the PA-specific journal
    meta field PULSE_BACKTRACE. This is the recommend journal practice
    instead of appending any furuther data to the logging message itself.
    
    Signed-off-by: Ahmed S. Darwish <darwish.07 at gmail.com>

diff --git a/src/pulse/pulseaudio.h b/src/pulse/pulseaudio.h
index f5c5b0d..5077e3b 100644
--- a/src/pulse/pulseaudio.h
+++ b/src/pulse/pulseaudio.h
@@ -140,6 +140,14 @@
  *  - `PULSE_LOG_SYSLOG`: If defined, force all client libraries to log
  *     their output using the syslog(3) mechanism. Default behavior is to
  *     log all output to stderr.
+ *  - `PULSE_LOG_JOURNAL`: If defined, force all client libraries to log
+ *     their output using the systemd journal. If both `PULSE_LOG_JOURNAL`
+ *     and `PULSE_LOG_SYSLOG` are defined, logging to the systemd journal
+ *     takes a higher precedence. Each message originating library file name
+ *     and function are included by default through the journal fields
+ *     `CODE_FILE`, `CODE_FUNC`, and `CODE_LINE`. Any backtrace attached to
+ *     the logging message is sent through the PulseAudio-specific journal
+ *     field `PULSE_BACKTRACE`.
  *  - `PULSE_LOG_COLORS`: If defined, enables colored logging output.
  *  - `PULSE_LOG_TIME`: If defined, include timestamps with each message.
  *  - `PULSE_LOG_FILE`: If defined, include each message originating file
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index 552d416..34ed041 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -60,6 +60,7 @@
 #include "log.h"
 
 #define ENV_LOG_SYSLOG "PULSE_LOG_SYSLOG"
+#define ENV_LOG_JOURNAL "PULSE_LOG_JOURNAL"
 #define ENV_LOG_LEVEL "PULSE_LOG"
 #define ENV_LOG_COLORS "PULSE_LOG_COLORS"
 #define ENV_LOG_PRINT_TIME "PULSE_LOG_TIME"
@@ -293,6 +294,11 @@ static void init_defaults(void) {
             target_override_set = true;
         }
 
+        if (getenv(ENV_LOG_JOURNAL)) {
+            target_override = PA_LOG_JOURNAL;
+            target_override_set = true;
+        }
+
         if ((e = getenv(ENV_LOG_LEVEL))) {
             maximum_level_override = (pa_log_level_t) atoi(e);
 
@@ -493,6 +499,7 @@ void pa_log_levelv_meta(
                                 "CODE_FILE=%s", file,
                                 "CODE_FUNC=%s", func,
                                 "CODE_LINE=%d", line,
+                                "PULSE_BACKTRACE=%s", pa_strempty(bt),
                                 NULL) < 0) {
 #ifdef HAVE_SYSLOG_H
                     pa_log_target new_target = { .type = PA_LOG_SYSLOG, .file = NULL };

commit 47bca4a800c345627acd20e783b55cfeef92a7bd
Author: Ahmed S. Darwish <darwish.07 at gmail.com>
Date:   Fri Aug 14 16:35:18 2015 +0200

    pulse: Document client libraries logging behavior
    
    Document how to modify the client libraries logging behvaior
    using any of the PA-specific environment variables.
    
    Using the PULSE_LOG_* environment variables makes debugging
    and tracing PA applications quite easy, thus the need for an
    official documentation text.
    
    Signed-off-by: Ahmed S. Darwish <darwish.07 at gmail.com>

diff --git a/src/pulse/pulseaudio.h b/src/pulse/pulseaudio.h
index 215ba6d..f5c5b0d 100644
--- a/src/pulse/pulseaudio.h
+++ b/src/pulse/pulseaudio.h
@@ -125,6 +125,39 @@
  * An error code can be turned into a human readable message using
  * pa_strerror().
  *
+ * \section logging_sec Logging
+ *
+ * You can configure different logging parameters for the PulseAudio client
+ * libraries. The following environment variables are recognized:
+ *
+ *  - `PULSE_LOG`: Maximum log level required. Bigger values result in a
+ *     more verbose logging output. The following values are recognized:
+ *     + `0`: Error messages
+ *     + `1`: Warning messages
+ *     + `2`: Notice messages
+ *     + `3`: Info messages
+ *     + `4`: Debug messages
+ *  - `PULSE_LOG_SYSLOG`: If defined, force all client libraries to log
+ *     their output using the syslog(3) mechanism. Default behavior is to
+ *     log all output to stderr.
+ *  - `PULSE_LOG_COLORS`: If defined, enables colored logging output.
+ *  - `PULSE_LOG_TIME`: If defined, include timestamps with each message.
+ *  - `PULSE_LOG_FILE`: If defined, include each message originating file
+ *     name.
+ *  - `PULSE_LOG_META`: If defined, include each message originating file
+ *     name and path relative to the PulseAudio source tree root.
+ *  - `PULSE_LOG_LEVEL`: If defined, include a log level prefix with each
+ *     message. Respectively, the prefixes "E", "W", "N", "I", "D" stands
+ *     for Error, Warning, Notice, Info, and Debugging.
+ *  - `PULSE_LOG_BACKTRACE`: Number of functions to display in the backtrace.
+ *     If this variable is not defined, or has a value of zero, no backtrace
+ *     is shown.
+ *  - `PULSE_LOG_BACKTRACE_SKIP`: Number of backtrace levels to skip, from
+ *     the function printing the log message downwards.
+ *  - `PULSE_LOG_NO_RATE_LIMIT`: If defined, do not rate limit the logging
+ *     output. Rate limiting skips certain log messages when their frequency
+ *     is considered too high.
+ *
  * \section pkgconfig pkg-config
  *
  * The PulseAudio libraries provide pkg-config snippets for the different



More information about the pulseaudio-commits mailing list