summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/logging.cc4
-rw-r--r--base/logging.h2
-rw-r--r--ceee/testing/utils/test_utils.cc10
-rw-r--r--ceee/testing/utils/test_utils.h3
4 files changed, 15 insertions, 4 deletions
diff --git a/base/logging.cc b/base/logging.cc
index ee4a4da..1ca00fb 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -420,6 +420,10 @@ void SetLogMessageHandler(LogMessageHandlerFunction handler) {
log_message_handler = handler;
}
+LogMessageHandlerFunction GetLogMessageHandler() {
+ return log_message_handler;
+}
+
// MSVC doesn't like complex extern templates and DLLs.
#if !defined(COMPILER_MSVC)
// Explicit instantiations for commonly used comparisons.
diff --git a/base/logging.h b/base/logging.h
index e1b088c..7315ea5 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -245,6 +245,7 @@ void SetShowErrorDialogs(bool enable_dialogs);
// (e.g. a silent one for Unit Tests)
typedef void (*LogAssertHandlerFunction)(const std::string& str);
void SetLogAssertHandler(LogAssertHandlerFunction handler);
+
// Sets the Log Report Handler that will be used to notify of check failures
// in non-debug mode. The default handler shows a dialog box and continues
// the execution, however clients can use this function to override with their
@@ -258,6 +259,7 @@ void SetLogReportHandler(LogReportHandlerFunction handler);
// should not be sent to other log destinations.
typedef bool (*LogMessageHandlerFunction)(int severity, const std::string& str);
void SetLogMessageHandler(LogMessageHandlerFunction handler);
+LogMessageHandlerFunction GetLogMessageHandler();
typedef int LogSeverity;
const LogSeverity LOG_INFO = 0;
diff --git a/ceee/testing/utils/test_utils.cc b/ceee/testing/utils/test_utils.cc
index 29b0bd6..48e522a 100644
--- a/ceee/testing/utils/test_utils.cc
+++ b/ceee/testing/utils/test_utils.cc
@@ -58,13 +58,17 @@ HRESULT GetConnectionCount(IUnknown* container,
}
+bool LogDisabler::DropMessageHandler(int severity, const std::string& str) {
+ return true;
+}
+
LogDisabler::LogDisabler() {
- initial_log_level_ = logging::GetMinLogLevel();
- logging::SetMinLogLevel(logging::LOG_FATAL + 1);
+ old_handler_ = logging::GetLogMessageHandler();
+ logging::SetLogMessageHandler(DropMessageHandler);
}
LogDisabler::~LogDisabler() {
- logging::SetMinLogLevel(initial_log_level_);
+ logging::SetLogMessageHandler(old_handler_);
}
PathServiceOverrider::PathServiceOverrider(int key, const FilePath& path) {
diff --git a/ceee/testing/utils/test_utils.h b/ceee/testing/utils/test_utils.h
index 28ddb94..55582be 100644
--- a/ceee/testing/utils/test_utils.h
+++ b/ceee/testing/utils/test_utils.h
@@ -67,7 +67,8 @@ class LogDisabler {
~LogDisabler();
private:
- int initial_log_level_;
+ logging::LogMessageHandlerFunction old_handler_;
+ static bool DropMessageHandler(int severity, const std::string& str);
};
// Overrides a path in the PathService singleton, replacing the