From 07b2ec5910e103fc38daa55d0fd0e931b66f5626 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 29 Nov 2011 01:20:21 -0800 Subject: Adding detailled logs, with timestamp and threadid. --- includes/Printer.h | 4 ++++ src/Printer.cc | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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"); -- cgit v1.2.3