diff options
author | Chris Wilson <chris+github@qwirx.com> | 2012-01-23 01:32:08 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2012-01-23 01:32:08 +0000 |
commit | cbc2639aec361e3832cc1adfc28079b49a89f0ad (patch) | |
tree | a58c866e4abb65c300d86e39801e3f5ee44c52d3 /lib/common/Logging.h | |
parent | ec36628676c99aa10f14f6f142d84e57143eda90 (diff) |
Allow overriding Logging::Guard to dump stack backtraces as well.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r-- | lib/common/Logging.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h index 4ddf760d..1fcbe59e 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -303,17 +303,33 @@ class Logging { private: Log::Level mOldLevel; + static int sGuardCount; + static Log::Level sOriginalLevel; public: Guard(Log::Level newLevel) { mOldLevel = Logging::GetGlobalLevel(); + if(sGuardCount == 0) + { + sOriginalLevel = mOldLevel; + } + sGuardCount++; Logging::SetGlobalLevel(newLevel); } ~Guard() { + sGuardCount--; Logging::SetGlobalLevel(mOldLevel); } + + static bool IsActive() { return (sGuardCount > 0); } + static Log::Level GetOriginalLevel() { return sOriginalLevel; } + static bool IsGuardingFrom(Log::Level originalLevel) + { + return IsActive() && + (int)sOriginalLevel >= (int)originalLevel; + } }; class Tagger |