mirror of
https://passt.top/passt
synced 2024-12-22 13:45:32 +00:00
log: Fetch log times with CLOCK_MONOTONIC, not CLOCK_REALTIME
We report relative timestamps in logs, so we want to avoid jumps in the system time. Suggested-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
e5c37ba0f4
commit
77c092ee5e
4
log.c
4
log.c
@ -68,7 +68,7 @@ void vlogmsg(bool newline, int pri, const char *format, va_list ap)
|
|||||||
struct timespec tp;
|
struct timespec tp;
|
||||||
|
|
||||||
if (debug_print) {
|
if (debug_print) {
|
||||||
clock_gettime(CLOCK_REALTIME, &tp);
|
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||||
fprintf(stderr, logtime_fmt_and_arg(&tp));
|
fprintf(stderr, logtime_fmt_and_arg(&tp));
|
||||||
fprintf(stderr, ": ");
|
fprintf(stderr, ": ");
|
||||||
}
|
}
|
||||||
@ -382,7 +382,7 @@ void logfile_write(bool newline, int pri, const char *format, va_list ap)
|
|||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (clock_gettime(CLOCK_REALTIME, &now))
|
if (clock_gettime(CLOCK_MONOTONIC, &now))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
n = snprintf(buf, BUFSIZ, logtime_fmt_and_arg(&now));
|
n = snprintf(buf, BUFSIZ, logtime_fmt_and_arg(&now));
|
||||||
|
Loading…
Reference in New Issue
Block a user