1 From 352c58357e5922b21d664c1f5a0b89a74f864f41 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 87ba3c21..2976601c 100644
18 --- a/spa/plugins/support/logger.c
19 +++ b/spa/plugins/support/logger.c
25 #include <sys/eventfd.h>
27 #include <spa/support/log.h>
28 @@ -70,6 +71,9 @@ impl_log_logv(struct spa_log *log,
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 @@ -86,8 +90,9 @@ impl_log_logv(struct spa_log *log,
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)) {