mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 05:28:01 +02:00
Add TID and SYSLOG_{IDENTIFIER,FACILITY,PID} to log messages
Systemd journal entries have several common entries: https://www.freedesktop.org/software/systemd/man/latest/systemd.journal-fields.html Add "SYSLOG_IDENTIFIER" to make it easier to find wireplumber messages. Add "SYSLOG_FACILITY" to avoid confusing programs that expect both or neither. Add "TID" and "SYSLOG_PID" to make debugging a little easier.
This commit is contained in:
parent
08d7e51efb
commit
2a5606e437
2 changed files with 23 additions and 1 deletions
13
lib/wp/log.c
13
lib/wp/log.c
|
|
@ -772,10 +772,17 @@ wp_log_fields_write_to_stream (WpLogFields *lf, FILE *s)
|
|||
static gboolean
|
||||
wp_log_fields_write_to_journal (WpLogFields *lf)
|
||||
{
|
||||
GLogField fields[6];
|
||||
GLogField fields[10];
|
||||
gsize n_fields = 0;
|
||||
g_autofree gchar *full_message = NULL;
|
||||
const gchar *message = lf->message ? lf->message : "";
|
||||
g_autofree gchar *pid = g_strdup_printf("%d", getpid());
|
||||
g_autofree gchar *tid = g_strdup_printf("%d", gettid());
|
||||
#ifdef HAS_SHORT_NAME
|
||||
const gchar *syslog_identifier = program_invocation_short_name;
|
||||
#else
|
||||
const gchar *syslog_identifier = g_get_prgname();
|
||||
#endif
|
||||
|
||||
if (lf->debug) {
|
||||
if (lf->file && lf->line && lf->func) {
|
||||
|
|
@ -797,6 +804,10 @@ wp_log_fields_write_to_journal (WpLogFields *lf)
|
|||
message = full_message = g_strdup_printf("%s: %s", lf->log_topic, message);
|
||||
}
|
||||
|
||||
fields[n_fields++] = (GLogField) { "SYSLOG_PID", pid, -1 };
|
||||
fields[n_fields++] = (GLogField) { "TID", tid, -1 };
|
||||
fields[n_fields++] = (GLogField) { "SYSLOG_IDENTIFIER", syslog_identifier, -1 };
|
||||
fields[n_fields++] = (GLogField) { "SYSLOG_FACILITY", "3", -1 };
|
||||
fields[n_fields++] = (GLogField) { "PRIORITY", log_level_info[lf->log_level].priority, -1 };
|
||||
if (lf->file)
|
||||
fields[n_fields++] = (GLogField) { "CODE_FILE", lf->file, -1 };
|
||||
|
|
|
|||
11
meson.build
11
meson.build
|
|
@ -42,6 +42,17 @@ add_project_arguments([
|
|||
], language: 'c'
|
||||
)
|
||||
|
||||
check_short_name = '''#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
void main() { program_invocation_short_name; }
|
||||
'''
|
||||
if cc.compiles(check_short_name, name : 'check short_name')
|
||||
add_project_arguments([
|
||||
'-DHAS_SHORT_NAME',
|
||||
], language: 'c'
|
||||
)
|
||||
endif
|
||||
|
||||
build_modules = get_option('modules')
|
||||
build_daemon = get_option('daemon')
|
||||
if build_daemon and not build_modules
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue