[PATCH 2/2] Show times in logfiles
Wilson Snyder
wsnyder at wsnyder.org
Thu May 6 10:43:13 MDT 2010
---
util.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/util.c b/util.c
index c50a7d5..ae48cf0 100644
--- a/util.c
+++ b/util.c
@@ -21,6 +21,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/time.h> // For timestamps - may not be portable
#include <fcntl.h>
#include <ctype.h>
#include <unistd.h>
@@ -53,7 +54,10 @@ void cc_log(const char *format, ...)
if (!logfile) logfile = fopen(cache_logfile, "a");
if (!logfile) return;
- fprintf(logfile, "[%-5d] ", getpid());
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+
+ fprintf(logfile, "[%10d.%06d,%-5d] ", (int)tv.tv_sec, (int)tv.tv_usec, getpid());
va_start(ap, format);
vfprintf(logfile, format, ap);
va_end(ap);
--
1.6.4.2
More information about the ccache
mailing list