From 1c083a6d69080e6db8beaef2150b17d641e513ea Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 7 Jun 2021 15:29:14 +1000 Subject: [PATCH] logger: clamp the log time to 5 digits In the interested of making the logs narrower, let's drop some digits from the clock_gettime() seconds value. Clamping to 5 digigts, this gives us just under 28h before we wrap which is likely good enough for debugging. --- spa/plugins/support/logger.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index a16990a89..ca6ff5504 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -78,7 +78,7 @@ impl_log_logv(void *object, #define RESERVED_LENGTH 24 struct impl *impl = object; - char timestamp[19] = {0}; + char timestamp[14] = {0}; char filename[64] = {0}; char location[1000 + RESERVED_LENGTH], *p, *s; static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" }; @@ -106,9 +106,8 @@ impl_log_logv(void *object, if (impl->timestamp) { struct timespec now; clock_gettime(CLOCK_MONOTONIC_RAW, &now); - spa_scnprintf(timestamp, sizeof(timestamp), "[%09lu.%06lu]", - now.tv_sec & 0x1FFFFFFF, now.tv_nsec / 1000); - + spa_scnprintf(timestamp, sizeof(timestamp), "[%05lu.%06lu]", + (now.tv_sec & 0x1FFFFFFF) % 100000, now.tv_nsec / 1000); } if (impl->line && line != 0) { s = strrchr(file, '/');