1 From 289f58b815badd54a32f2409bae7abd7e5474327 Mon Sep 17 00:00:00 2001
2 From: George Kiagiadakis <george.kiagiadakis@collabora.com>
3 Date: Wed, 3 Jul 2019 17:47:46 +0300
4 Subject: [PATCH] logger: print timestamps on logged messages
6 Timestamps have usec precision and the seconds are limited
7 to 9 digits. Usually what matters in these messages is to spot
8 delays between printouts and not really what is the absolute
11 Upstream-Status: Submitted [https://github.com/PipeWire/pipewire/pull/164]
13 spa/plugins/support/logger.c | 9 +++++++--
14 1 file changed, 7 insertions(+), 2 deletions(-)
16 diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c
17 index 9ed2896b..4100102c 100644
18 --- a/spa/plugins/support/logger.c
19 +++ b/spa/plugins/support/logger.c
26 #include <spa/support/log.h>
27 #include <spa/support/loop.h>
28 @@ -72,6 +73,9 @@ impl_log_logv(void *object,
29 const char *prefix = "", *suffix = "";
32 + struct timespec now;
34 + clock_gettime(CLOCK_MONOTONIC_RAW, &now);
36 if ((do_trace = (level == SPA_LOG_LEVEL_TRACE && impl->have_source)))
38 @@ -88,8 +92,9 @@ impl_log_logv(void *object,
41 vsnprintf(text, sizeof(text), fmt, args);
42 - size = snprintf(location, sizeof(location), "%s[%s][%s:%i %s()] %s%s\n",
43 - prefix, levels[level], strrchr(file, '/') + 1, line, func, text, suffix);
44 + size = snprintf(location, sizeof(location), "%s[%s][%09lu.%06lu][%s:%i %s()] %s%s\n",
45 + prefix, levels[level], now.tv_sec & 0x1FFFFFFF, now.tv_nsec / 1000,
46 + strrchr(file, '/') + 1, line, func, text, suffix);
48 if (SPA_UNLIKELY(do_trace)) {