From 0fdab36710a3d74839c09bbaf48cbc502b898ebd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 13 Aug 2016 21:04:42 +0200 Subject: COMMON: Introduce --debug-channels-only command line flag. Many of our systems currently generate significant amount of debug output on deeper levels. Now, when your engine is using Debug Channels, you might want to show that debug information only, which is currently not possible, as the generic output will be mixed in your output. Alternative solution would be to implement possibility to specify per-channel debug levels. --- common/debug.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'common/debug.cpp') diff --git a/common/debug.cpp b/common/debug.cpp index 182b28afdf..ce34a00445 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -30,6 +30,7 @@ // TODO: Move gDebugLevel into namespace Common. int gDebugLevel = -1; +bool gDebugChannelsOnly = false; namespace Common { @@ -137,6 +138,9 @@ static void debugHelper(const char *s, va_list va, bool caret = true) { void debug(const char *s, ...) { va_list va; + if (gDebugChannelsOnly) + return; + va_start(va, s); debugHelper(s, va); va_end(va); @@ -145,7 +149,7 @@ void debug(const char *s, ...) { void debug(int level, const char *s, ...) { va_list va; - if (level > gDebugLevel) + if (level > gDebugLevel || gDebugChannelsOnly) return; va_start(va, s); @@ -157,6 +161,9 @@ void debug(int level, const char *s, ...) { void debugN(const char *s, ...) { va_list va; + if (gDebugChannelsOnly) + return; + va_start(va, s); debugHelper(s, va, false); va_end(va); @@ -165,7 +172,7 @@ void debugN(const char *s, ...) { void debugN(int level, const char *s, ...) { va_list va; - if (level > gDebugLevel) + if (level > gDebugLevel || gDebugChannelsOnly) return; va_start(va, s); -- cgit v1.2.3 From 0ab903a9e2416f329439d094bc6b6864a3454e37 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 19 Aug 2016 09:38:25 +0200 Subject: COMMON: Added checkers for debug channels. Sometimes there is a need to add debug execution and enable it from the command line. Now it is possible, both with debug levels and channels --- common/debug.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common/debug.cpp') diff --git a/common/debug.cpp b/common/debug.cpp index ce34a00445..c61fc63dea 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -120,6 +120,18 @@ bool DebugManager::isDebugChannelEnabled(uint32 channel) { } // End of namespace Common +bool debugLevelSet(int level) { + return level <= gDebugLevel; +} + +bool debugChannelSet(int level, uint32 debugChannels) { + if (gDebugLevel != 11) + if (level > gDebugLevel || !(DebugMan.isDebugChannelEnabled(debugChannels))) + return false; + + return true; +} + #ifndef DISABLE_TEXT_CONSOLE -- cgit v1.2.3