Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: base/test/mock_log.cc

Issue 2497833002: support multiple log message handlers in base/logging.h (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/mock_log.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/mock_log.cc
diff --git a/base/test/mock_log.cc b/base/test/mock_log.cc
index a09000d8ed7f9e3080ff06a64cb060c76fa591f6..83cb246efa9184db4f853a73ccd6fcc47e7cb8c3 100644
--- a/base/test/mock_log.cc
+++ b/base/test/mock_log.cc
@@ -31,8 +31,7 @@ void MockLog::StartCapturingLogs() {
is_capturing_logs_ = true;
g_instance_ = this;
- previous_handler_ = logging::GetLogMessageHandler();
- logging::SetLogMessageHandler(LogMessageHandler);
+ logging::AddLogMessageHandler(LogMessageHandler);
}
void MockLog::StopCapturingLogs() {
@@ -45,15 +44,14 @@ void MockLog::StopCapturingLogs() {
RAW_CHECK(g_instance_ == this);
is_capturing_logs_ = false;
- logging::SetLogMessageHandler(previous_handler_);
+ logging::RemoveLogMessageHandler(LogMessageHandler);
g_instance_ = nullptr;
}
// static
bool MockLog::LogMessageHandler(int severity,
- const char* file,
+ const std::string& file,
int line,
- size_t message_start,
const std::string& str) {
// gMock guarantees thread-safety for calling a mocked method
// (https://github.com/google/googlemock/blob/master/googlemock/docs/CookBook.md#using-google-mock-and-threads)
@@ -61,7 +59,7 @@ bool MockLog::LogMessageHandler(int severity,
// with LogMessageHandler.
AutoLock scoped_lock(g_lock);
- return g_instance_->Log(severity, file, line, message_start, str);
+ return g_instance_->Log(severity, file, line, str);
}
} // namespace test
« no previous file with comments | « base/test/mock_log.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698