Index: base/logging.h |
diff --git a/base/logging.h b/base/logging.h |
index 08189b6114bc020f10905d83e4165bdca67126a1..e927d1daf737e9f168aef5dcc3362eee268611fb 100644 |
--- a/base/logging.h |
+++ b/base/logging.h |
@@ -279,14 +279,35 @@ 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 |
+// Derive the LogMessageHandler that gets passed every log message before |
grt (UTC plus 2)
2016/08/01 21:17:44
Please review the style guide section on comments
wychen
2016/08/01 23:11:03
Done.
|
// 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(); |
+class BASE_EXPORT LogMessageHandler { |
+ public: |
+ // Returns true 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. |
+ virtual bool OnMessage(int severity, const char* file, int line, |
+ size_t message_start, const std::string& str) = 0; |
+ virtual ~LogMessageHandler(); |
grt (UTC plus 2)
2016/08/01 21:17:44
Move up; ctors and dtors precede other methods.
wychen
2016/08/01 23:11:04
Done.
|
+ protected: |
+ LogMessageHandler(); |
+}; |
+ |
+BASE_EXPORT size_t LogMessageHandlerCountForTesting(); |
grt (UTC plus 2)
2016/08/01 21:17:44
If this is only used by base_unittests, it should
wychen
2016/08/01 23:11:04
If I don't export it, component build would fail.
grt (UTC plus 2)
2016/08/02 07:25:46
Meh. I didn't realize base_unittests linked to bas
|
+ |
+// Derive the LogMessageListener that gets passed every log message before |
+// it's sent to LogMessageHandler. If hijacking message is not |
+// needed, use this one instead of LogMessageHandler. |
+class BASE_EXPORT LogMessageListener { |
+ public: |
+ virtual void OnMessage(int severity, const char* file, int line, |
+ size_t message_start, const std::string& str) = 0; |
+ virtual ~LogMessageListener(); |
+ protected: |
+ LogMessageListener(); |
+}; |
+ |
+BASE_EXPORT size_t LogMessageListenerCountForTesting(); |
typedef int LogSeverity; |
const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity |