summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-11-29 01:20:21 -0800
committerPixel <pixel@nobis-crew.org>2011-11-29 01:20:21 -0800
commit07b2ec5910e103fc38daa55d0fd0e931b66f5626 (patch)
tree426d3a5e49cb22b380f7e2c50a23b507606486b4
parent7e19ed346d2305dd63edd01ed8aa79e0dfb02d01 (diff)
Adding detailled logs, with timestamp and threadid.
-rw-r--r--includes/Printer.h4
-rw-r--r--src/Printer.cc12
2 files changed, 15 insertions, 1 deletions
diff --git a/includes/Printer.h b/includes/Printer.h
index dee5adc..e321557 100644
--- a/includes/Printer.h
+++ b/includes/Printer.h
@@ -71,7 +71,11 @@ class Printer {
static void enable(uint32_t levels = M_ALL) { getPrinter()->m_verbosity |= levels; }
static void disable(uint32_t levels = M_ALL) { getPrinter()->m_verbosity &= ~levels; }
+ static void setDetailled(bool enable) { getPrinter()->m_detailledLogs = enable; }
+
+ private:
uint32_t m_verbosity;
+ bool m_detailledLogs;
};
};
diff --git a/src/Printer.cc b/src/Printer.cc
index 9216ec8..026ee1a 100644
--- a/src/Printer.cc
+++ b/src/Printer.cc
@@ -1,3 +1,4 @@
+#include "ev++.h"
#include "Printer.h"
#include "Main.h"
#include "Local.h"
@@ -15,7 +16,10 @@ static const char * prefixes[] = {
"(**) ",
};
-Balau::Printer::Printer() : m_verbosity(M_STATUS | M_WARNING | M_ERROR | M_ENGINE_DEBUG) {
+Balau::Printer::Printer() : m_verbosity(M_STATUS | M_WARNING | M_ERROR | M_ENGINE_DEBUG), m_detailledLogs(false) {
+#ifdef DEBUG
+ m_detailledLogs = true;
+#endif
if (!localPrinter.getGlobal())
localPrinter.setGlobal(this);
}
@@ -37,6 +41,12 @@ void Balau::Printer::_log(uint32_t level, const char * fmt, va_list ap) {
break;
m_lock.enter();
+ if (m_detailledLogs) {
+ struct ev_loop * loop = ev_default_loop(0);
+ ev_now_update(loop);
+ ev_tstamp now = ev_now(loop);
+ _print("[%15.8f:%08x] ", now, pthread_self());
+ }
_print(prefixes[i]);
_print(fmt, ap);
_print("\n");