From b1d8896cbac3c283bb5c0a724f7e9f28623fbf82 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 2 Nov 2012 10:14:20 +0100 Subject: Added date as prefix to output. --- debug.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/debug.cc b/debug.cc index d3c1dce..4776c62 100644 --- a/debug.cc +++ b/debug.cc @@ -32,6 +32,7 @@ #include //#include #include +#include //#include "mutex.h" @@ -75,12 +76,16 @@ int __debug(const char *func, const int line, const enum __debug_class cl, const char *ch, const char *fmt, ...) { + time_t rawtime = time(NULL); + char* timestr = ctime(&rawtime); + *(timestr+strlen(timestr)-1) = '\0'; + // MutexAutolock m(mutex); int ret = 0; if(__debug_enabled(cl, ch)) { if((unsigned)cl < NELEM(debug_class_str)) - ret += fprintf(logfp, "%u %s:%s:%s:%d ", - gettid(), debug_class_str[(unsigned)cl], ch, func, line); + ret += fprintf(logfp, "[%s] %u %s:%s:%s:%d ", + timestr, gettid(), debug_class_str[(unsigned)cl], ch, func, line); if(fmt) { va_list va; va_start(va, fmt); -- cgit v1.2.3