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

Unified Diff: base/logging_win.cc

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address grt's comments 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: base/logging_win.cc
diff --git a/base/logging_win.cc b/base/logging_win.cc
index 319ae8a9d38186aa7ffc6466f574c2a795a1832c..421e71cb159379e24872863fedbd7cb1a893f7c9 100644
--- a/base/logging_win.cc
+++ b/base/logging_win.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/logging_win.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include <initguid.h> // NOLINT
@@ -14,6 +15,9 @@ using base::win::EtwMofEvent;
DEFINE_GUID(kLogEventId,
0x7fe69228, 0x633e, 0x4f06, 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7);
+LogEventProvider::WinLogMessageHandler* LogEventProvider::log_handler_ =
+ nullptr;
+
LogEventProvider::LogEventProvider() : old_log_level_(LOG_NONE) {
}
@@ -22,9 +26,9 @@ LogEventProvider* LogEventProvider::GetInstance() {
LogEventProvider>>::get();
}
-bool LogEventProvider::LogMessage(logging::LogSeverity severity,
- const char* file, int line, size_t message_start,
- const std::string& message) {
+bool LogEventProvider::WinLogMessageHandler::OnMessage(
+ logging::LogSeverity severity, const char* file, int line,
+ size_t message_start, const std::string& message) {
EtwEventLevel level = TRACE_LEVEL_NONE;
// Convert the log severity to the most appropriate ETW trace level.
@@ -88,7 +92,8 @@ bool LogEventProvider::LogMessage(logging::LogSeverity severity,
provider->Log(event.get());
}
- // Don't increase verbosity in other log destinations.
+ // Don't increase verbosity in other log destinations below this handler
+ // in the handler stack.
if (severity < provider->old_log_level_)
return true;
@@ -102,11 +107,13 @@ void LogEventProvider::Initialize(const GUID& provider_name) {
provider->Register();
// Register our message handler with logging.
- SetLogMessageHandler(LogMessage);
+ log_handler_ = new WinLogMessageHandler();
grt (UTC plus 2) 2016/08/05 20:13:30 can log_handler_ be a non-static member of the pro
wychen 2016/08/12 21:32:39 Initialize() is a static member, so I think it's n
grt (UTC plus 2) 2016/08/15 07:36:32 I disagree. Initialize is part of the public API.
wychen 2016/08/17 17:08:54 Done.
}
void LogEventProvider::Uninitialize() {
LogEventProvider::GetInstance()->Unregister();
+ delete log_handler_;
+ log_handler_ = nullptr;
}
void LogEventProvider::OnEventsEnabled() {
« base/logging.cc ('K') | « base/logging_win.h ('k') | base/test/mock_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698