OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // a dialog box or not. | 238 // a dialog box or not. |
239 // Dialogs are not shown by default. | 239 // Dialogs are not shown by default. |
240 void SetShowErrorDialogs(bool enable_dialogs); | 240 void SetShowErrorDialogs(bool enable_dialogs); |
241 | 241 |
242 // Sets the Log Assert Handler that will be used to notify of check failures. | 242 // Sets the Log Assert Handler that will be used to notify of check failures. |
243 // The default handler shows a dialog box and then terminate the process, | 243 // The default handler shows a dialog box and then terminate the process, |
244 // however clients can use this function to override with their own handling | 244 // however clients can use this function to override with their own handling |
245 // (e.g. a silent one for Unit Tests) | 245 // (e.g. a silent one for Unit Tests) |
246 typedef void (*LogAssertHandlerFunction)(const std::string& str); | 246 typedef void (*LogAssertHandlerFunction)(const std::string& str); |
247 void SetLogAssertHandler(LogAssertHandlerFunction handler); | 247 void SetLogAssertHandler(LogAssertHandlerFunction handler); |
| 248 |
248 // Sets the Log Report Handler that will be used to notify of check failures | 249 // Sets the Log Report Handler that will be used to notify of check failures |
249 // in non-debug mode. The default handler shows a dialog box and continues | 250 // in non-debug mode. The default handler shows a dialog box and continues |
250 // the execution, however clients can use this function to override with their | 251 // the execution, however clients can use this function to override with their |
251 // own handling. | 252 // own handling. |
252 typedef void (*LogReportHandlerFunction)(const std::string& str); | 253 typedef void (*LogReportHandlerFunction)(const std::string& str); |
253 void SetLogReportHandler(LogReportHandlerFunction handler); | 254 void SetLogReportHandler(LogReportHandlerFunction handler); |
254 | 255 |
255 // Sets the Log Message Handler that gets passed every log message before | 256 // Sets the Log Message Handler that gets passed every log message before |
256 // it's sent to other log destinations (if any). | 257 // it's sent to other log destinations (if any). |
257 // Returns true to signal that it handled the message and the message | 258 // Returns true to signal that it handled the message and the message |
258 // should not be sent to other log destinations. | 259 // should not be sent to other log destinations. |
259 typedef bool (*LogMessageHandlerFunction)(int severity, const std::string& str); | 260 typedef bool (*LogMessageHandlerFunction)(int severity, const std::string& str); |
260 void SetLogMessageHandler(LogMessageHandlerFunction handler); | 261 void SetLogMessageHandler(LogMessageHandlerFunction handler); |
| 262 LogMessageHandlerFunction GetLogMessageHandler(); |
261 | 263 |
262 typedef int LogSeverity; | 264 typedef int LogSeverity; |
263 const LogSeverity LOG_INFO = 0; | 265 const LogSeverity LOG_INFO = 0; |
264 const LogSeverity LOG_WARNING = 1; | 266 const LogSeverity LOG_WARNING = 1; |
265 const LogSeverity LOG_ERROR = 2; | 267 const LogSeverity LOG_ERROR = 2; |
266 const LogSeverity LOG_ERROR_REPORT = 3; | 268 const LogSeverity LOG_ERROR_REPORT = 3; |
267 const LogSeverity LOG_FATAL = 4; | 269 const LogSeverity LOG_FATAL = 4; |
268 const LogSeverity LOG_NUM_SEVERITIES = 5; | 270 const LogSeverity LOG_NUM_SEVERITIES = 5; |
269 | 271 |
270 // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode | 272 // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 #elif NOTIMPLEMENTED_POLICY == 4 | 884 #elif NOTIMPLEMENTED_POLICY == 4 |
883 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG | 885 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG |
884 #elif NOTIMPLEMENTED_POLICY == 5 | 886 #elif NOTIMPLEMENTED_POLICY == 5 |
885 #define NOTIMPLEMENTED() do {\ | 887 #define NOTIMPLEMENTED() do {\ |
886 static int count = 0;\ | 888 static int count = 0;\ |
887 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ | 889 LOG_IF(ERROR, 0 == count++) << NOTIMPLEMENTED_MSG;\ |
888 } while(0) | 890 } while(0) |
889 #endif | 891 #endif |
890 | 892 |
891 #endif // BASE_LOGGING_H_ | 893 #endif // BASE_LOGGING_H_ |
OLD | NEW |