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@gmail.com>
This commit is contained in:
Ahmed S. Darwish 2015-08-14 18:47:32 +02:00 committed by Arun Raghavan
parent c93903d99a
commit ac5b7b8d5c
2 changed files with 15 additions and 0 deletions

View file

@ -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 };