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

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: clean up, MockLog uses listener Created 4 years, 5 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_win.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 fd148aa2694700e910e79810635e60fb466e2b56..7efc0424fdcb0c57c8bb02975526d49a08ac68bd 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -282,11 +282,31 @@ 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.
+// should not be sent to other log destinations, including other handlers
+// below the current one in the stack.
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();
+BASE_EXPORT void PushLogMessageHandler(LogMessageHandlerFunction handler);
+// When popping, GetTopLogMessageHandler() is supposed to be |expected|.
+BASE_EXPORT void PopLogMessageHandler(LogMessageHandlerFunction expected);
+BASE_EXPORT LogMessageHandlerFunction GetTopLogMessageHandler();
+
+// Sets the Log Message Listener that gets passed every log message before
+// it's sent to LogMessageHandlerFunctions. If hijacking message is not
+// needed, use this one instead of LogMessageHandlerFunction.
+typedef void (*LogMessageListenerFunction)(int severity,
+ const char* file, int line, size_t message_start, const std::string& str);
+
+class BASE_EXPORT ScopedLogMessageListener {
+ public:
+ ScopedLogMessageListener(LogMessageListenerFunction listener);
wychen 2016/07/09 21:21:19 explicit?
wychen 2016/07/18 15:44:12 Done.
+ ~ScopedLogMessageListener();
+ private:
+ LogMessageListenerFunction listener_;
+};
+
+BASE_EXPORT void AddLogMessageListener(LogMessageListenerFunction listener);
+BASE_EXPORT void RemoveLogMessageListener(LogMessageListenerFunction listener);
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_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698