diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Handle.h | 1 | ||||
-rw-r--r-- | includes/Printer.h | 22 | ||||
-rw-r--r-- | includes/Task.h | 5 |
3 files changed, 25 insertions, 3 deletions
diff --git a/includes/Handle.h b/includes/Handle.h index 9f1486a..0e19e50 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -1,6 +1,7 @@ #pragma once #include <Exceptions.h> +#include <Printer.h> namespace Balau { 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 <stdarg.h> #include <BString.h> +#include <Threads.h> 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; } diff --git a/includes/Task.h b/includes/Task.h index 3d99d26..691d47f 100644 --- a/includes/Task.h +++ b/includes/Task.h @@ -3,8 +3,9 @@ #include <stdlib.h> #include <coro.h> #include <ev++.h> -#include <Exceptions.h> #include <vector> +#include <Exceptions.h> +#include <Printer.h> namespace Balau { @@ -31,7 +32,7 @@ class Callback { class BaseEvent { public: - BaseEvent() : m_cb(NULL), m_signal(false), m_task(NULL) { } + BaseEvent() : m_cb(NULL), m_signal(false), m_task(NULL) { Printer::elog(E_TASK, "Creating event at %p", this); } virtual ~BaseEvent() { if (m_cb) delete m_cb; } bool gotSignal() { return m_signal; } void doSignal(); |