From 7db161f6dd144760b2912026d992837ef80ca7e7 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Fri, 13 Mar 2015 21:09:33 -0700 Subject: [PATCH] rocker: timestamp on the debug logs helps correlate with events in the VM Signed-off-by: David Ahern Signed-off-by: Scott Feldman Signed-off-by: Jiri Pirko Message-id: 1426306173-24884-10-git-send-email-sfeldma@gmail.com Signed-off-by: Stefan Hajnoczi --- hw/net/rocker/rocker.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/net/rocker/rocker.h b/hw/net/rocker/rocker.h index 6ae74ff..b3310b6 100644 --- a/hw/net/rocker/rocker.h +++ b/hw/net/rocker/rocker.h @@ -23,7 +23,16 @@ #if defined(DEBUG_ROCKER) # define DPRINTF(fmt, ...) \ - do { fprintf(stderr, "ROCKER: " fmt, ## __VA_ARGS__); } while (0) + do { \ + struct timeval tv; \ + char timestr[64]; \ + time_t now; \ + gettimeofday(&tv, NULL); \ + now = tv.tv_sec; \ + strftime(timestr, sizeof(timestr), "%T", localtime(&now)); \ + fprintf(stderr, "%s.%06ld ", timestr, tv.tv_usec); \ + fprintf(stderr, "ROCKER: " fmt, ## __VA_ARGS__); \ + } while (0) #else static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...) { -- 2.7.4