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

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: use ReadWriteLock, add 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..92035e00e5ea52e073d525901a8f1d55900c8218 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_ =
grt (UTC plus 2) 2016/08/15 07:36:32 nit: // static just before this
wychen 2016/08/17 17:08:54 No longer static.
+ nullptr;
+
LogEventProvider::LogEventProvider() : old_log_level_(LOG_NONE) {
}
@@ -22,8 +26,11 @@ LogEventProvider* LogEventProvider::GetInstance() {
LogEventProvider>>::get();
}
-bool LogEventProvider::LogMessage(logging::LogSeverity severity,
- const char* file, int line, size_t message_start,
+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;
@@ -88,7 +95,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 +110,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/15 07:36:32 DCHECK_EQ(nullptr, log_handler_);
wychen 2016/08/17 17:08:54 Used unique_ptr.
}
void LogEventProvider::Uninitialize() {
LogEventProvider::GetInstance()->Unregister();
+ delete log_handler_;
grt (UTC plus 2) 2016/08/15 07:36:32 DCHECK_NE(nullptr, log_handler_);
wychen 2016/08/17 17:08:54 Used unique_ptr.
+ log_handler_ = nullptr;
}
void LogEventProvider::OnEventsEnabled() {

Powered by Google App Engine
This is Rietveld 408576698