Chromium Code Reviews| Index: base/logging.h |
| diff --git a/base/logging.h b/base/logging.h |
| index f06535dada056725121d0a31c0c745bca9c8f0f0..b4739039417538e62e31a9f50de92c883da9412a 100644 |
| --- a/base/logging.h |
| +++ b/base/logging.h |
| @@ -279,14 +279,33 @@ 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 |
| // 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: |
| + explicit LogMessageHandler(); |
|
grt (UTC plus 2)
2016/07/27 20:38:21
nit: omit "explicit" and make the ctor protected,
wychen
2016/08/01 16:12:26
Done.
|
| + // 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(); |
| +}; |
| + |
| +BASE_EXPORT unsigned LogMessageHandlerCountForTesting(); |
| + |
| +// 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: |
| + explicit LogMessageListener(); |
| + virtual void OnMessage(int severity, const char* file, int line, |
|
grt (UTC plus 2)
2016/07/27 20:38:21
maybe it's simpler to replace this single-method i
grt (UTC plus 2)
2016/07/28 06:28:48
I see that this is counter to Brett's suggestion,
wychen
2016/08/01 16:12:25
CallbackList handles thread safety nicely, and I t
wychen
2016/08/01 16:12:25
Done.
|
| + size_t message_start, const std::string& str) = 0; |
| + virtual ~LogMessageListener(); |
| +}; |
| + |
| +BASE_EXPORT unsigned LogMessageListenerCountForTesting(); |
| typedef int LogSeverity; |
| const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity |