aboutsummaryrefslogtreecommitdiff
path: root/common/debug.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-30 19:23:00 +0000
committerJohannes Schickel2010-01-30 19:23:00 +0000
commit676bebe2be5d7cd685feb29059997f2a4b4f4442 (patch)
tree121bde9a49c08200a31b4800ec7aebdb014d7f91 /common/debug.cpp
parent87856c545c5b46a0d6062cf4f953e7ee4e0e2d8e (diff)
downloadscummvm-rg350-676bebe2be5d7cd685feb29059997f2a4b4f4442.tar.gz
scummvm-rg350-676bebe2be5d7cd685feb29059997f2a4b4f4442.tar.bz2
scummvm-rg350-676bebe2be5d7cd685feb29059997f2a4b4f4442.zip
- Call the special debug channels "channels" consistently. (Formerly sometimes they were refered to as "levels").
- Along with it add some more descriptive commentary about what is the intention behind debug channels. svn-id: r47727
Diffstat (limited to 'common/debug.cpp')
-rw-r--r--common/debug.cpp59
1 files changed, 29 insertions, 30 deletions
diff --git a/common/debug.cpp b/common/debug.cpp
index f6dc065c88..ed18639124 100644
--- a/common/debug.cpp
+++ b/common/debug.cpp
@@ -48,16 +48,14 @@
// TODO: Move gDebugLevel into namespace Common.
int gDebugLevel = -1;
-
-
namespace Common {
namespace {
-typedef HashMap<String, DebugChannel, IgnoreCase_Hash, IgnoreCase_EqualTo> DebugLevelMap;
+typedef HashMap<String, DebugChannel, IgnoreCase_Hash, IgnoreCase_EqualTo> DebugChannelMap;
-static DebugLevelMap gDebugLevels;
-static uint32 gDebugLevelsEnabled = 0;
+static DebugChannelMap gDebugChannels;
+static uint32 gDebugChannelsEnabled = 0;
struct DebugLevelComperator {
bool operator()(const DebugChannel &l, const DebugChannel &r) {
@@ -65,27 +63,27 @@ struct DebugLevelComperator {
}
};
-}
+} // end of anonymous namespace
-bool addDebugChannel(uint32 level, const String &name, const String &description) {
- if (gDebugLevels.contains(name)) {
- warning("Duplicate declaration of engine debug level '%s'", name.c_str());
- }
- gDebugLevels[name] = DebugChannel(level, name, description);
+bool addDebugChannel(uint32 channel, const String &name, const String &description) {
+ if (gDebugChannels.contains(name))
+ warning("Duplicate declaration of engine debug channel '%s'", name.c_str());
+
+ gDebugChannels[name] = DebugChannel(channel, name, description);
return true;
}
void clearAllDebugChannels() {
- gDebugLevelsEnabled = 0;
- gDebugLevels.clear();
+ gDebugChannelsEnabled = 0;
+ gDebugChannels.clear();
}
bool enableDebugChannel(const String &name) {
- DebugLevelMap::iterator i = gDebugLevels.find(name);
+ DebugChannelMap::iterator i = gDebugChannels.find(name);
- if (i != gDebugLevels.end()) {
- gDebugLevelsEnabled |= i->_value.level;
+ if (i != gDebugChannels.end()) {
+ gDebugChannelsEnabled |= i->_value.channel;
i->_value.enabled = true;
return true;
@@ -95,10 +93,10 @@ bool enableDebugChannel(const String &name) {
}
bool disableDebugChannel(const String &name) {
- DebugLevelMap::iterator i = gDebugLevels.find(name);
+ DebugChannelMap::iterator i = gDebugChannels.find(name);
- if (i != gDebugLevels.end()) {
- gDebugLevelsEnabled &= ~i->_value.level;
+ if (i != gDebugChannels.end()) {
+ gDebugChannelsEnabled &= ~i->_value.channel;
i->_value.enabled = false;
return true;
@@ -110,19 +108,19 @@ bool disableDebugChannel(const String &name) {
DebugChannelList listDebugChannels() {
DebugChannelList tmp;
- for (DebugLevelMap::iterator i = gDebugLevels.begin(); i != gDebugLevels.end(); ++i)
+ for (DebugChannelMap::iterator i = gDebugChannels.begin(); i != gDebugChannels.end(); ++i)
tmp.push_back(i->_value);
sort(tmp.begin(), tmp.end(), DebugLevelComperator());
return tmp;
}
-bool isDebugChannelEnabled(uint32 level) {
+bool isDebugChannelEnabled(uint32 channel) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel == 11)
return true;
-// return gDebugLevelsEnabled & (1 << level);
- return gDebugLevelsEnabled & level;
+ else
+ return (gDebugChannelsEnabled & channel) != 0;
}
bool isDebugChannelEnabled(const String &name) {
@@ -131,10 +129,11 @@ bool isDebugChannelEnabled(const String &name) {
return true;
// Search for the debug level with the given name and check if it is enabled
- DebugLevelMap::iterator i = gDebugLevels.find(name);
- if (i != gDebugLevels.end())
+ DebugChannelMap::iterator i = gDebugChannels.find(name);
+ if (i != gDebugChannels.end())
return i->_value.enabled;
- return false;
+ else
+ return false;
}
@@ -220,7 +219,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::gDebugLevelsEnabled & debugChannels))
+ if (level > gDebugLevel || !(Common::gDebugChannelsEnabled & debugChannels))
return;
va_start(va, s);
@@ -233,7 +232,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::gDebugLevelsEnabled & debugChannels))
+ if (level > gDebugLevel || !(Common::gDebugChannelsEnabled & debugChannels))
return;
va_start(va, s);
@@ -246,7 +245,7 @@ void debugC(uint32 debugChannels, const char *s, ...) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel != 11)
- if (!(Common::gDebugLevelsEnabled & debugChannels))
+ if (!(Common::gDebugChannelsEnabled & debugChannels))
return;
va_start(va, s);
@@ -259,7 +258,7 @@ void debugCN(uint32 debugChannels, const char *s, ...) {
// Debug level 11 turns on all special debug level messages
if (gDebugLevel != 11)
- if (!(Common::gDebugLevelsEnabled & debugChannels))
+ if (!(Common::gDebugChannelsEnabled & debugChannels))
return;
va_start(va, s);