Merge branch 'spa_support_logger_tid' into 'master'

spa: support: logger: print thread id for each message

See merge request pipewire/pipewire!2748
This commit is contained in:
Barnabás Pőcze 2026-03-12 18:32:32 +01:00
commit 40c330c3c8

View file

@ -2,12 +2,16 @@
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */ /* SPDX-License-Identifier: MIT */
#include "config.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include <threads.h>
#include <fnmatch.h> #include <fnmatch.h>
#include <spa/support/log.h> #include <spa/support/log.h>
@ -92,6 +96,14 @@ impl_log_logtv(void *object,
spa_strbuf_append(&msg, "%s[%s]", prefix, levels[level]); 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) { if (impl->local_timestamp) {
char buf[64]; char buf[64];
struct timespec now; struct timespec now;