From 10d0f503fb68946c265bad18dd755fdc816075c1 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 17 Oct 2011 21:02:52 -0700 Subject: Adding an early version of the 'engine debug' facility. --- includes/Printer.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'includes/Printer.h') diff --git a/includes/Printer.h b/includes/Printer.h index d8ba9cf..cd24059 100644 --- a/includes/Printer.h +++ b/includes/Printer.h @@ -2,6 +2,7 @@ #include #include +#include namespace Balau { @@ -14,7 +15,19 @@ enum { M_ALERT = 32, M_ALL = M_DEBUG | M_INFO | M_STATUS | M_WARNING | M_ERROR | M_ALERT, - M_MAX = M_ALERT, + + M_ENGINE_DEBUG = 64, + M_MAX = M_ENGINE_DEBUG, +}; + +enum { + E_STRING = 1, + E_TASK = 2, + E_EVENT = 4, + E_HANDLE = 8, + E_INPUT = 16, + E_SOCKET = 32, + E_THREAD = 64, }; class Printer { @@ -25,6 +38,7 @@ class Printer { void _print(const char * fmt, ...); void _log(uint32_t level, const char * fmt, va_list ap); + Lock m_lock; public: Printer(); @@ -38,6 +52,12 @@ class Printer { static void print(const char * fmt, ...) { va_list ap; va_start(ap, fmt); vprint(fmt, ap); va_end(ap); } static void vprint(const char * fmt, va_list ap) { getPrinter()->_print(fmt, ap); } +#ifdef DEBUG + static void elog(uint32_t engine, const char * fmt, ...) { va_list ap; va_start(ap, fmt); getPrinter()->_log(M_ENGINE_DEBUG, fmt, ap); } +#else + static void elog(uint32_t engine, const char * fmt, ...) { } +#endif + static void enable(uint32_t levels = M_ALL) { getPrinter()->m_verbosity |= levels; } static void disable(uint32_t levels = M_ALL) { getPrinter()->m_verbosity &= ~levels; } -- cgit v1.2.3