From: Michael Stapelberg Date: Sun, 10 Jul 2011 21:11:21 +0000 (+0200) Subject: log: display time in microseconds when DEBUG_TIMING is set X-Git-Tag: tree-pr4~41 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=48f5166daf684c53a319824222909d0d9225d557;p=i3%2Fi3 log: display time in microseconds when DEBUG_TIMING is set --- diff --git a/src/log.c b/src/log.c index 99c2d4d3..22b7fffe 100644 --- a/src/log.c +++ b/src/log.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "util.h" #include "log.h" @@ -89,7 +90,13 @@ void vlog(char *fmt, va_list args) { struct tm *tmp = localtime(&t); /* Generate time prefix */ strftime(timebuf, sizeof(timebuf), "%x %X - ", tmp); +#ifdef DEBUG_TIMING + struct timeval tv; + gettimeofday(&tv, NULL); + printf("%s%d.%d - ", timebuf, tv.tv_sec, tv.tv_usec); +#else printf("%s", timebuf); +#endif vprintf(fmt, args); }