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

Unified Diff: base/logging.h

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
« no previous file with comments | « no previous file | base/logging.cc » ('j') | base/logging.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.h
diff --git a/base/logging.h b/base/logging.h
index 08189b6114bc020f10905d83e4165bdca67126a1..f76572f0f8633632f5ef8c5ca6112183422086f6 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -279,14 +279,36 @@ BASE_EXPORT void SetShowErrorDialogs(bool enable_dialogs);
typedef void (*LogAssertHandlerFunction)(const std::string& str);
BASE_EXPORT void SetLogAssertHandler(LogAssertHandlerFunction handler);
-// Sets the Log Message Handler that gets passed every log message before
-// it's sent to other log destinations (if any).
-// Returns true to signal that it handled the message and the message
-// should not be sent to other log destinations.
-typedef bool (*LogMessageHandlerFunction)(int severity,
- const char* file, int line, size_t message_start, const std::string& str);
-BASE_EXPORT void SetLogMessageHandler(LogMessageHandlerFunction handler);
-BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler();
+// LogMessageHandler is the callback interface for log message handling.
+// OnMessage() is called for every log message before it's sent to other log
+// destinations (if any), but after LogMessageListener.
+// Return true in OnMessage() to signal that it handled the message and the
+// message should not be sent to other log destinations, including other
+// handlers added before the current one.
+class BASE_EXPORT LogMessageHandler {
+ public:
+ virtual ~LogMessageHandler();
+ virtual bool OnMessage(int severity, const char* file, int line,
+ size_t message_start, const std::string& str) = 0;
grt (UTC plus 2) 2016/08/05 20:13:30 please use "git cl format"
wychen 2016/08/12 21:32:39 Done.
+ protected:
grt (UTC plus 2) 2016/08/05 20:13:30 nit: blank line before this (below, too)
wychen 2016/08/12 21:32:39 Done.
+ LogMessageHandler();
+};
+
+BASE_EXPORT size_t LogMessageHandlerCountForTesting();
+
+// LogMessageListener is similar to LogMessageHandler except that this
+// interface doesn't support message hijacking, and is preferred over
+// LogMessageHandler if hijacking is not needed.
+class BASE_EXPORT LogMessageListener {
+ public:
+ virtual ~LogMessageListener();
+ virtual void OnMessage(int severity, const char* file, int line,
+ size_t message_start, const std::string& str) = 0;
+ protected:
+ LogMessageListener();
+};
+
+BASE_EXPORT size_t LogMessageListenerCountForTesting();
typedef int LogSeverity;
const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity
« no previous file with comments | « no previous file | base/logging.cc » ('j') | base/logging.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698