From 002e7a703accee39cf6e31855e9d6f35476d1751 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 1 Sep 2008 02:39:27 +0200 Subject: output relative timestamps in addition to absolute timestamps when logging --- src/pulsecore/log.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/pulsecore/log.c') diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index 5b799991..d7318081 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -139,18 +139,28 @@ void pa_log_levelv_meta( location[0] = 0; if (getenv(ENV_LOGTIME)) { - static pa_usec_t start; - pa_usec_t u; + static pa_usec_t start, last; + pa_usec_t u, a, r; u = pa_rtclock_usec(); PA_ONCE_BEGIN { start = u; + last = u; } PA_ONCE_END; - u -= start; + r = u - last; + a = u - start; - pa_snprintf(timestamp, sizeof(timestamp), "(%4llu.%03llu) ", (unsigned long long) (u / PA_USEC_PER_SEC), (unsigned long long) (((u / PA_USEC_PER_MSEC)) % 1000)); + /* This is not thread safe, but this is a debugging tool only + * anyway. */ + last = u; + + pa_snprintf(timestamp, sizeof(timestamp), "(%4llu.%03llu|%4llu.%03llu) ", + (unsigned long long) (a / PA_USEC_PER_SEC), + (unsigned long long) (((a / PA_USEC_PER_MSEC)) % 1000), + (unsigned long long) (r / PA_USEC_PER_SEC), + (unsigned long long) (((r / PA_USEC_PER_MSEC)) % 1000)); } else timestamp[0] = 0; -- cgit