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

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: revert slow, try adding back handlers Created 3 years, 12 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 afd73754ca19963be1f6f74e75d15fdb070a88a6..cb7350ca86a691a0a71cf77c296edf1085038a28 100644
--- a/chrome/test/chromedriver/logging.cc
+++ b/chrome/test/chromedriver/logging.cc
@@ -97,11 +97,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);
@@ -238,7 +246,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);
logging::LoggingSettings logging_settings;
logging_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;

Powered by Google App Engine
This is Rietveld 408576698