aboutsummaryrefslogtreecommitdiff
path: root/common/debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/debug.cpp')
-rw-r--r--common/debug.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/common/debug.cpp b/common/debug.cpp
index 86371f4091..30f4534f56 100644
--- a/common/debug.cpp
+++ b/common/debug.cpp
@@ -24,8 +24,6 @@
#include "common/debug.h"
#include "common/util.h"
-#include "common/hashmap.h"
-#include "common/hash-str.h"
#include <stdarg.h> // For va_list etc.
@@ -48,24 +46,21 @@
// TODO: Move gDebugLevel into namespace Common.
int gDebugLevel = -1;
+DECLARE_SINGLETON(Common::DebugManager)
+
namespace Common {
namespace {
-typedef HashMap<String, DebugChannel, IgnoreCase_Hash, IgnoreCase_EqualTo> DebugChannelMap;
-
-static DebugChannelMap gDebugChannels;
-static uint32 gDebugChannelsEnabled = 0;
-
struct DebugLevelComperator {
- bool operator()(const DebugChannel &l, const DebugChannel &r) {
+ bool operator()(const DebugManager::DebugChannel &l, const DebugManager::DebugChannel &r) {
return (l.name.compareToIgnoreCase(r.name) < 0);
}
};
} // end of anonymous namespace
-bool addDebugChannel(uint32 channel, const String &name, const String &description) {
+bool DebugManager::addDebugChannel(uint32 channel, const String &name, const String &description) {
if (gDebugChannels.contains(name))
warning("Duplicate declaration of engine debug channel '%s'", name.c_str());
@@ -74,12 +69,12 @@ bool addDebugChannel(uint32 channel, const String &name, const String &descripti
return true;
}
-void clearAllDebugChannels() {
+void DebugManager::clearAllDebugChannels() {
gDebugChannelsEnabled = 0;
gDebugChannels.clear();
}
-bool enableDebugChannel(const String &name) {
+bool DebugManager::enableDebugChannel(const String &name) {
DebugChannelMap::iterator i = gDebugChannels.find(name);
if (i != gDebugChannels.end()) {
@@ -92,7 +87,7 @@ bool enableDebugChannel(const String &name) {
}
}
-bool disableDebugChannel(const String &name) {
+bool DebugManager::disableDebugChannel(const String &name) {
DebugChannelMap::iterator i = gDebugChannels.find(name);
if (i != gDebugChannels.end()) {
@@ -106,7 +101,7 @@ bool disableDebugChannel(const String &name) {
}
-DebugChannelList listDebugChannels() {
+DebugManager::DebugChannelList DebugManager::listDebugChannels() {
DebugChannelList tmp;
for (DebugChannelMap::iterator i = gDebugChannels.begin(); i != gDebugChannels.end(); ++i)
tmp.push_back(i->_value);
@@ -115,7 +110,7 @@ DebugChannelList listDebugChannels() {
return tmp;
}
-bool isDebugChannelEnabled(uint32 channel) {
+bool DebugManager::isDebugChannelEnabled(uint32 channel) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel == 11)
return true;
@@ -206,7 +201,7 @@ void debugC(int level, uint32 debugChannels, const char *s, ...) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel != 11)
- if (level > gDebugLevel || !(Common::gDebugChannelsEnabled & debugChannels))
+ if (level > gDebugLevel || !(DebugMan.isDebugChannelEnabled(debugChannels)))
return;
va_start(va, s);
@@ -219,7 +214,7 @@ void debugCN(int level, uint32 debugChannels, const char *s, ...) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel != 11)
- if (level > gDebugLevel || !(Common::gDebugChannelsEnabled & debugChannels))
+ if (level > gDebugLevel || !(DebugMan.isDebugChannelEnabled(debugChannels)))
return;
va_start(va, s);
@@ -232,7 +227,7 @@ void debugC(uint32 debugChannels, const char *s, ...) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel != 11)
- if (!(Common::gDebugChannelsEnabled & debugChannels))
+ if (!(DebugMan.isDebugChannelEnabled(debugChannels)))
return;
va_start(va, s);
@@ -245,7 +240,7 @@ void debugCN(uint32 debugChannels, const char *s, ...) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel != 11)
- if (!(Common::gDebugChannelsEnabled & debugChannels))
+ if (!(DebugMan.isDebugChannelEnabled(debugChannels)))
return;
va_start(va, s);