From 3273ba633310752d580f74590e6d5c9bd0c0a2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 12 Mar 2026 00:21:08 +0100 Subject: [PATCH] spa: support: logger: print thread id for each message The thread id is very useful for debugging, add it to the every log message so that it does not have to be inferred from the content itself. This is already done in the systemd journal logger, so implement it here as well. Before: [I][00:13:11.120303] pw.context | [ pipewire.c: 585 pw_init()] version 1.7.0 After: [I][365073][00:13:11.120303] pw.context | [ pipewire.c: 585 pw_init()] version 1.7.0 --- spa/plugins/support/logger.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index 9a20ff241..7d0b14c1f 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -2,12 +2,16 @@ /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ /* SPDX-License-Identifier: MIT */ +#include "config.h" + #include +#include #include #include #include #include #include +#include #include #include @@ -92,6 +96,14 @@ impl_log_logtv(void *object, spa_strbuf_append(&msg, "%s[%s]", prefix, levels[level]); +#ifdef HAVE_GETTID + static thread_local pid_t tid; + if (SPA_UNLIKELY(tid == 0)) + tid = gettid(); + + spa_strbuf_append(&msg, "[%jd]", (intmax_t) tid); +#endif + if (impl->local_timestamp) { char buf[64]; struct timespec now;