Index: base/logging_win.cc |
diff --git a/base/logging_win.cc b/base/logging_win.cc |
index 319ae8a9d38186aa7ffc6466f574c2a795a1832c..115c542c5ef436dc084d87e0b9c9c5428943dbc9 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,8 @@ using base::win::EtwMofEvent; |
DEFINE_GUID(kLogEventId, |
0x7fe69228, 0x633e, 0x4f06, 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7); |
+static std::unique_ptr<WinLogMessageHandler> g_log_handler; |
grt (UTC plus 2)
2016/07/27 20:38:21
move this into the unnamed namespace and remove "s
wychen
2016/08/01 16:12:26
Done, and used raw pointer instead.
|
+ |
LogEventProvider::LogEventProvider() : old_log_level_(LOG_NONE) { |
} |
@@ -22,7 +25,7 @@ LogEventProvider* LogEventProvider::GetInstance() { |
LogEventProvider>>::get(); |
} |
-bool LogEventProvider::LogMessage(logging::LogSeverity severity, |
+bool 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 +91,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 +106,12 @@ void LogEventProvider::Initialize(const GUID& provider_name) { |
provider->Register(); |
// Register our message handler with logging. |
- SetLogMessageHandler(LogMessage); |
+ g_log_handler = base::MakeUnique<WinLogMessageHandler>(); |
} |
void LogEventProvider::Uninitialize() { |
LogEventProvider::GetInstance()->Unregister(); |
+ g_log_handler.reset(); |
} |
void LogEventProvider::OnEventsEnabled() { |