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

Unified Diff: chrome/test/chromedriver/logging.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments, deque for listeners, reentrant test Created 4 years, 4 months 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
Index: chrome/test/chromedriver/logging.cc
diff --git a/chrome/test/chromedriver/logging.cc b/chrome/test/chromedriver/logging.cc
index 67f60e4acff040e479f71ccc41daaa2c4ebed961..a38ba95b53690fa8b5d9fa00d91a9faf764e4e91 100644
--- a/chrome/test/chromedriver/logging.cc
+++ b/chrome/test/chromedriver/logging.cc
@@ -96,11 +96,19 @@ bool InternalIsVLogOn(int vlog_level) {
return GetLevelFromSeverity(vlog_level * -1) >= level;
}
-bool HandleLogMessage(int severity,
- const char* file,
- int line,
- size_t message_start,
- const std::string& str) {
+class LogMessageHandler : logging::LogMessageHandler {
+ bool OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) override;
+};
+
+bool LogMessageHandler::OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) {
Log::Level level = GetLevelFromSeverity(severity);
std::string message = str.substr(message_start);
@@ -237,7 +245,8 @@ bool InitLogging() {
false, // enable_thread_id
false, // enable_timestamp
false); // enable_tickcount
- logging::SetLogMessageHandler(&HandleLogMessage);
+ auto* handler = new LogMessageHandler(); // Intentionally leak this instance.
+ CHECK(handler);
brettw 2016/11/14 22:01:31 Normally we wouldn't bother asserting the malloc r
wychen 2016/11/18 21:14:00 Done.
logging::LoggingSettings logging_settings;
logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;

Powered by Google App Engine
This is Rietveld 408576698