diff --git a/base/logging.cc b/base/logging.cc index ee4a4da64760c58e7aa1a511a4b29035b8916d30..1ca00fb95fc83589dbabc470a73fdfcef569dd5c 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 e1b088c44afe3282aa9de1cc4d814e0426f42af0..7315ea5134e78e9933b83b243cab847a03b3bc4d 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 29b0bd66c9d9edfbdd7673193fb159baea924f12..48e522a71c64911409f4e71f211aa90f838b6a8c 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 28ddb94db31ffe6ce220263fc0a69f48804bb953..55582be8f11e130325f66cbcb28cdfdfa81c7432 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