summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2012-11-02 10:14:20 +0100
committerJonas Suhr Christensen <jsc@umbraculum.org>2012-11-02 10:14:20 +0100
commitb1d8896cbac3c283bb5c0a724f7e9f28623fbf82 (patch)
treef3ef1e021ad69c05edd6a7373416f4f61e97150b
parenta32e833c161a0dbcb94e939e75465ee302a8e0bb (diff)
Added date as prefix to output.
-rw-r--r--debug.cc9
1 files 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 <string.h>
//#include <pthread.h>
#include <string>
+#include <time.h>
//#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);