| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_LOGGING_H_ | 5 #ifndef BASE_LOGGING_H_ |
| 6 #define BASE_LOGGING_H_ | 6 #define BASE_LOGGING_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cassert> | 10 #include <cassert> |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // Dialogs are not shown by default. | 273 // Dialogs are not shown by default. |
| 274 BASE_EXPORT void SetShowErrorDialogs(bool enable_dialogs); | 274 BASE_EXPORT void SetShowErrorDialogs(bool enable_dialogs); |
| 275 | 275 |
| 276 // Sets the Log Assert Handler that will be used to notify of check failures. | 276 // Sets the Log Assert Handler that will be used to notify of check failures. |
| 277 // The default handler shows a dialog box and then terminate the process, | 277 // The default handler shows a dialog box and then terminate the process, |
| 278 // however clients can use this function to override with their own handling | 278 // however clients can use this function to override with their own handling |
| 279 // (e.g. a silent one for Unit Tests) | 279 // (e.g. a silent one for Unit Tests) |
| 280 typedef void (*LogAssertHandlerFunction)(const std::string& str); | 280 typedef void (*LogAssertHandlerFunction)(const std::string& str); |
| 281 BASE_EXPORT void SetLogAssertHandler(LogAssertHandlerFunction handler); | 281 BASE_EXPORT void SetLogAssertHandler(LogAssertHandlerFunction handler); |
| 282 | 282 |
| 283 // Sets the Log Message Handler that gets passed every log message before | 283 // LogMessageListener is the callback interface for log message listening. |
| 284 // it's sent to other log destinations (if any). | 284 // OnMessage() is called for every log message before it's sent to other log |
| 285 // Returns true to signal that it handled the message and the message | 285 // destinations (if any). |
| 286 // should not be sent to other log destinations. | 286 class BASE_EXPORT LogMessageListener { |
| 287 typedef bool (*LogMessageHandlerFunction)(int severity, | 287 public: |
| 288 const char* file, int line, size_t message_start, const std::string& str); | 288 virtual ~LogMessageListener(); |
| 289 BASE_EXPORT void SetLogMessageHandler(LogMessageHandlerFunction handler); | 289 virtual void OnMessage(int severity, |
| 290 BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler(); | 290 const char* file, |
| 291 int line, |
| 292 size_t message_start, |
| 293 const std::string& str) = 0; |
| 294 |
| 295 protected: |
| 296 LogMessageListener(); |
| 297 }; |
| 298 |
| 299 BASE_EXPORT size_t LogMessageListenerCountForTesting(); |
| 291 | 300 |
| 292 typedef int LogSeverity; | 301 typedef int LogSeverity; |
| 293 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity | 302 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity |
| 294 // Note: the log severities are used to index into the array of names, | 303 // Note: the log severities are used to index into the array of names, |
| 295 // see log_severity_names. | 304 // see log_severity_names. |
| 296 const LogSeverity LOG_INFO = 0; | 305 const LogSeverity LOG_INFO = 0; |
| 297 const LogSeverity LOG_WARNING = 1; | 306 const LogSeverity LOG_WARNING = 1; |
| 298 const LogSeverity LOG_ERROR = 2; | 307 const LogSeverity LOG_ERROR = 2; |
| 299 const LogSeverity LOG_FATAL = 3; | 308 const LogSeverity LOG_FATAL = 3; |
| 300 const LogSeverity LOG_NUM_SEVERITIES = 4; | 309 const LogSeverity LOG_NUM_SEVERITIES = 4; |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 #elif NOTIMPLEMENTED_POLICY == 5 | 1027 #elif NOTIMPLEMENTED_POLICY == 5 |
| 1019 #define NOTIMPLEMENTED() do {\ | 1028 #define NOTIMPLEMENTED() do {\ |
| 1020 static bool logged_once = false;\ | 1029 static bool logged_once = false;\ |
| 1021 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 1030 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 1022 logged_once = true;\ | 1031 logged_once = true;\ |
| 1023 } while(0);\ | 1032 } while(0);\ |
| 1024 EAT_STREAM_PARAMETERS | 1033 EAT_STREAM_PARAMETERS |
| 1025 #endif | 1034 #endif |
| 1026 | 1035 |
| 1027 #endif // BASE_LOGGING_H_ | 1036 #endif // BASE_LOGGING_H_ |
| OLD | NEW |