rocker: timestamp on the debug logs helps correlate with events in the VM
authorDavid Ahern <dsahern@gmail.com>
Sat, 14 Mar 2015 04:09:33 +0000 (21:09 -0700)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 11 May 2015 13:49:04 +0000 (14:49 +0100)
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Message-id: 1426306173-24884-10-git-send-email-sfeldma@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw/net/rocker/rocker.h

index 6ae74ff..b3310b6 100644 (file)
 
 #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, ...)
 {