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

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: 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 | « base/logging_win.h ('k') | base/test/mock_log.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging_win.cc
diff --git a/base/logging_win.cc b/base/logging_win.cc
index 319ae8a9d38186aa7ffc6466f574c2a795a1832c..11e8e3e4d3a0442699d96b67f9e128e5561141a5 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
@@ -17,13 +18,18 @@ DEFINE_GUID(kLogEventId,
LogEventProvider::LogEventProvider() : old_log_level_(LOG_NONE) {
}
+LogEventProvider::~LogEventProvider() {}
+
LogEventProvider* LogEventProvider::GetInstance() {
return base::Singleton<LogEventProvider, base::StaticMemorySingletonTraits<
LogEventProvider>>::get();
}
-bool LogEventProvider::LogMessage(logging::LogSeverity severity,
- const char* file, int line, size_t message_start,
+void LogEventProvider::WinLogMessageListener::OnMessage(
+ logging::LogSeverity severity,
+ const char* file,
+ int line,
+ size_t message_start,
const std::string& message) {
EtwEventLevel level = TRACE_LEVEL_NONE;
@@ -51,7 +57,7 @@ bool LogEventProvider::LogMessage(logging::LogSeverity severity,
// or if we're post-atexit handling.
LogEventProvider* provider = LogEventProvider::GetInstance();
if (provider == NULL || level > provider->enable_level())
- return false;
+ return;
// And now log the event.
if (provider->enable_flags() & ENABLE_LOG_MESSAGE_ONLY) {
@@ -88,11 +94,7 @@ bool LogEventProvider::LogMessage(logging::LogSeverity severity,
provider->Log(event.get());
}
- // Don't increase verbosity in other log destinations.
- if (severity < provider->old_log_level_)
- return true;
-
- return false;
+ // The log verbosity for other log destinations is increased.
}
void LogEventProvider::Initialize(const GUID& provider_name) {
@@ -101,12 +103,14 @@ void LogEventProvider::Initialize(const GUID& provider_name) {
provider->set_provider_name(provider_name);
provider->Register();
- // Register our message handler with logging.
- SetLogMessageHandler(LogMessage);
+ // Register our message listener with logging.
+ provider->log_listener_ = base::MakeUnique<WinLogMessageListener>();
}
void LogEventProvider::Uninitialize() {
- LogEventProvider::GetInstance()->Unregister();
+ LogEventProvider* provider = LogEventProvider::GetInstance();
+ provider->Unregister();
+ provider->log_listener_.reset();
}
void LogEventProvider::OnEventsEnabled() {
« no previous file with comments | « 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