mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
logger: print timestamps on logged messages
Timestamps have usec precision and the seconds are limited to 9 digits. Usually what matters in these messages is to spot delays between printouts and not really what is the absolute time of the system.
This commit is contained in:
parent
ac24743b2e
commit
53f93c2bde
1 changed files with 13 additions and 2 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/support/loop.h>
|
||||
|
|
@ -88,8 +89,18 @@ impl_log_logv(void *object,
|
|||
}
|
||||
|
||||
vsnprintf(text, sizeof(text), fmt, args);
|
||||
size = snprintf(location, sizeof(location), "%s[%s][%s:%i %s()] %s%s\n",
|
||||
prefix, levels[level], strrchr(file, '/') + 1, line, func, text, suffix);
|
||||
|
||||
if (level >= SPA_LOG_LEVEL_DEBUG) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
||||
|
||||
size = snprintf(location, sizeof(location), "%s[%s][%09lu.%06lu][%s:%i %s()] %s%s\n",
|
||||
prefix, levels[level], now.tv_sec & 0x1FFFFFFF, now.tv_nsec / 1000,
|
||||
strrchr(file, '/') + 1, line, func, text, suffix);
|
||||
} else {
|
||||
size = snprintf(location, sizeof(location), "%s[%s][%s:%i %s()] %s%s\n",
|
||||
prefix, levels[level], strrchr(file, '/') + 1, line, func, text, suffix);
|
||||
}
|
||||
|
||||
if (SPA_UNLIKELY(do_trace)) {
|
||||
uint32_t index;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue