Chromium Code Reviews| 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 // LogMessageHandler is the callback interface for log message handling. |
| 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 |
|
grt (UTC plus 2)
2017/01/04 09:12:19
nit: i think it's more clear to say messages are s
| |
| 285 // Returns true to signal that it handled the message and the message | 285 // destinations (if any), but after LogMessageListener. |
| 286 // should not be sent to other log destinations. | 286 // Return true in OnMessage() to signal that it handled the message and the |
| 287 typedef bool (*LogMessageHandlerFunction)(int severity, | 287 // message should not be sent to other log destinations, including other |
| 288 const char* file, int line, size_t message_start, const std::string& str); | 288 // handlers added before the current one. |
| 289 BASE_EXPORT void SetLogMessageHandler(LogMessageHandlerFunction handler); | 289 class BASE_EXPORT LogMessageHandler { |
| 290 BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler(); | 290 public: |
| 291 virtual ~LogMessageHandler(); | |
| 292 virtual bool OnMessage(int severity, | |
| 293 const char* file, | |
| 294 int line, | |
| 295 size_t message_start, | |
| 296 const std::string& str) = 0; | |
| 297 | |
| 298 protected: | |
| 299 LogMessageHandler(); | |
| 300 }; | |
| 301 | |
| 302 BASE_EXPORT size_t LogMessageHandlerCountForTesting(); | |
| 303 | |
| 304 // LogMessageListener is similar to LogMessageHandler except that this | |
| 305 // interface doesn't support message hijacking, and is preferred over | |
| 306 // LogMessageHandler if hijacking is not needed. | |
| 307 class BASE_EXPORT LogMessageListener { | |
| 308 public: | |
| 309 virtual ~LogMessageListener(); | |
| 310 virtual void OnMessage(int severity, | |
| 311 const char* file, | |
| 312 int line, | |
| 313 size_t message_start, | |
| 314 const std::string& str) = 0; | |
| 315 | |
| 316 protected: | |
| 317 LogMessageListener(); | |
| 318 }; | |
| 319 | |
| 320 BASE_EXPORT size_t LogMessageListenerCountForTesting(); | |
| 291 | 321 |
| 292 typedef int LogSeverity; | 322 typedef int LogSeverity; |
| 293 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity | 323 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity |
| 294 // Note: the log severities are used to index into the array of names, | 324 // Note: the log severities are used to index into the array of names, |
| 295 // see log_severity_names. | 325 // see log_severity_names. |
| 296 const LogSeverity LOG_INFO = 0; | 326 const LogSeverity LOG_INFO = 0; |
| 297 const LogSeverity LOG_WARNING = 1; | 327 const LogSeverity LOG_WARNING = 1; |
| 298 const LogSeverity LOG_ERROR = 2; | 328 const LogSeverity LOG_ERROR = 2; |
| 299 const LogSeverity LOG_FATAL = 3; | 329 const LogSeverity LOG_FATAL = 3; |
| 300 const LogSeverity LOG_NUM_SEVERITIES = 4; | 330 const LogSeverity LOG_NUM_SEVERITIES = 4; |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 #elif NOTIMPLEMENTED_POLICY == 5 | 1048 #elif NOTIMPLEMENTED_POLICY == 5 |
| 1019 #define NOTIMPLEMENTED() do {\ | 1049 #define NOTIMPLEMENTED() do {\ |
| 1020 static bool logged_once = false;\ | 1050 static bool logged_once = false;\ |
| 1021 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 1051 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 1022 logged_once = true;\ | 1052 logged_once = true;\ |
| 1023 } while(0);\ | 1053 } while(0);\ |
| 1024 EAT_STREAM_PARAMETERS | 1054 EAT_STREAM_PARAMETERS |
| 1025 #endif | 1055 #endif |
| 1026 | 1056 |
| 1027 #endif // BASE_LOGGING_H_ | 1057 #endif // BASE_LOGGING_H_ |
| OLD | NEW |