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

Unified Diff: net/tools/stress_cache/stress_cache.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 11 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
« no previous file with comments | « net/test/gtest_util.h ('k') | remoting/client/plugin/chromoting_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/stress_cache/stress_cache.cc
diff --git a/net/tools/stress_cache/stress_cache.cc b/net/tools/stress_cache/stress_cache.cc
index fefcd72f23d7177f48a743d6bc33cf610fe72b67..99271f9cd7fd87d292af425eed94aff21fb7e09c 100644
--- a/net/tools/stress_cache/stress_cache.cc
+++ b/net/tools/stress_cache/stress_cache.cc
@@ -384,19 +384,24 @@ void CrashHandler(const std::string& str) {
base::debug::BreakDebugger();
}
-bool MessageHandler(int severity, const char* file, int line,
- size_t message_start, const std::string& str) {
- const size_t kMaxMessageLen = 48;
- char message[kMaxMessageLen];
- size_t len = std::min(str.length() - message_start, kMaxMessageLen - 1);
-
- memcpy(message, str.c_str() + message_start, len);
- message[len] = '\0';
+class MessageListener : logging::LogMessageListener {
+ public:
+ void OnMessage(int severity,
+ const char* file,
+ int line,
+ size_t message_start,
+ const std::string& str) override {
+ const size_t kMaxMessageLen = 48;
+ char message[kMaxMessageLen];
+ size_t len = std::min(str.length() - message_start, kMaxMessageLen - 1);
+
+ memcpy(message, str.c_str() + message_start, len);
+ message[len] = '\0';
#if !defined(DISK_CACHE_TRACE_TO_LOG)
- disk_cache::Trace("%s", message);
+ disk_cache::Trace("%s", message);
#endif
- return false;
-}
+ }
+};
// -----------------------------------------------------------------------
@@ -415,7 +420,7 @@ int main(int argc, const char* argv[]) {
return MasterCode();
logging::SetLogAssertHandler(CrashHandler);
- logging::SetLogMessageHandler(MessageHandler);
+ MessageListener listener;
#if defined(OS_WIN)
logging::LogEventProvider::Initialize(kStressCacheTraceProviderName);
« no previous file with comments | « net/test/gtest_util.h ('k') | remoting/client/plugin/chromoting_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698