Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-12-17 20:03:46 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:04:08 +0300
commit12f01e0ab9b92ccda7bb749ff5885a24cc660459 (patch)
tree9c52ef43a04d4893f96fb7ab68dcab18b3361337 /base
parentf7197df58cc0ae1e77073bfe4e01b58ce3769ec7 (diff)
Helper to suppress unnecessary log messages in unit tests.
Diffstat (limited to 'base')
-rw-r--r--base/logging.hpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/base/logging.hpp b/base/logging.hpp
index 384d33d7d3..f97af58be6 100644
--- a/base/logging.hpp
+++ b/base/logging.hpp
@@ -25,6 +25,19 @@ namespace my
void LogMessageDefault(LogLevel level, SrcPoint const & srcPoint, string const & msg);
void LogMessageTests(LogLevel level, SrcPoint const & srcPoint, string const & msg);
+
+ /// Scope Guard to temporarily suppress specific log level, for example, in unit tests:
+ /// ...
+ /// {
+ /// LogLevelSuppressor onlyLERRORAndLCriticalLogsAreEnabled;
+ /// TEST(SomeFunctionWhichHasDebugOrInfoOrWarningLogs(), ());
+ /// }
+ struct LogLevelSuppressor
+ {
+ LogLevel m_old = g_LogLevel;
+ LogLevelSuppressor(LogLevel temporaryLogLevel = LERROR) { g_LogLevel = temporaryLogLevel; }
+ ~LogLevelSuppressor() { g_LogLevel = m_old; }
+ };
}
using ::my::LDEBUG;