diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-02-08 12:20:22 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-02-08 12:20:22 +0000 |
commit | 0b9e7e39e4ca4b561b0aef0953a6fccc336628f2 (patch) | |
tree | ed11e95049e6c3ff66abda6c62b66d4922ee357b /lib/common/Logging.h | |
parent | 046a872a59fc1d7bb681994bd79c60392b733f77 (diff) |
Allow a logging tagger to temporarily replace the current tag.
Sometimes useful to replace instead of appending to the current tag.
The old tag will be reinstated when the tagger is destroyed.
Diffstat (limited to 'lib/common/Logging.h')
-rw-r--r-- | lib/common/Logging.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/common/Logging.h b/lib/common/Logging.h index 0a708caf..55d09c91 100644 --- a/lib/common/Logging.h +++ b/lib/common/Logging.h @@ -384,16 +384,19 @@ class Logging { private: std::string mOldTag; + bool mReplace; public: Tagger() - : mOldTag(Logging::GetProgramName()) + : mOldTag(Logging::GetProgramName()), + mReplace(false) { } - Tagger(const std::string& rTempTag) - : mOldTag(Logging::GetProgramName()) + Tagger(const std::string& rTempTag, bool replace = false) + : mOldTag(Logging::GetProgramName()), + mReplace(replace) { - Logging::SetProgramName(mOldTag + " " + rTempTag); + Change(rTempTag); } ~Tagger() { @@ -402,7 +405,14 @@ class Logging void Change(const std::string& newTempTag) { - Logging::SetProgramName(mOldTag + " " + newTempTag); + if(mReplace || mOldTag.empty()) + { + Logging::SetProgramName(newTempTag); + } + else + { + Logging::SetProgramName(mOldTag + " " + newTempTag); + } } }; }; |