diff options
Diffstat (limited to 'common/debug.cpp')
-rw-r--r-- | common/debug.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/common/debug.cpp b/common/debug.cpp index cbd1db5f45..11b36e7d12 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -25,8 +25,7 @@ #include "common/debug.h" #include "common/util.h" #include "common/hashmap.h" - -#include "engines/engine.h" +#include "common/hash-str.h" #include <stdarg.h> // For va_list etc. @@ -47,6 +46,12 @@ #endif + +// TODO: Move gDebugLevel into namespace Common. +int gDebugLevel = -1; + + + namespace Common { namespace { @@ -135,10 +140,15 @@ bool isDebugChannelEnabled(const String &name) { } -} // End of namespace Common +static OutputFormatter s_debugOutputFormatter = 0; + +void setDebugOutputFormatter(OutputFormatter f) { + s_debugOutputFormatter = f; +} + +} // End of namespace Common -int gDebugLevel = -1; #ifndef DISABLE_TEXT_CONSOLE @@ -149,8 +159,8 @@ static void debugHelper(const char *s, va_list va, bool caret = true) { // Next, give the active engine (if any) a chance to augment the message, // but only if not used from debugN. - if (g_engine && caret) { - g_engine->errorString(in_buf, buf, STRINGBUFLEN); + if (Common::s_debugOutputFormatter) { + (*Common::s_debugOutputFormatter)(buf, in_buf, STRINGBUFLEN); } else { strncpy(buf, in_buf, STRINGBUFLEN); } |