Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: base/logging.h

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Use LazyIsntance and stl stack. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <cstring> 11 #include <cstring>
12 #include <sstream> 12 #include <sstream>
13 #include <string> 13 #include <string>
14 #include <type_traits> 14 #include <type_traits>
15 #include <utility> 15 #include <utility>
16 16
17 #include "base/base_export.h" 17 #include "base/base_export.h"
18 #include "base/callback_forward.h"
18 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
19 #include "base/debug/debugger.h" 20 #include "base/debug/debugger.h"
20 #include "base/macros.h" 21 #include "base/macros.h"
21 #include "base/template_util.h" 22 #include "base/template_util.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 24
24 // 25 //
25 // Optional message capabilities 26 // Optional message capabilities
26 // ----------------------------- 27 // -----------------------------
27 // Assertion failed messages and fatal errors are displayed in a dialog box 28 // Assertion failed messages and fatal errors are displayed in a dialog box
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // 135 //
135 // The supported severity levels for macros that allow you to specify one 136 // The supported severity levels for macros that allow you to specify one
136 // are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. 137 // are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
137 // 138 //
138 // Very important: logging a message at the FATAL severity level causes 139 // Very important: logging a message at the FATAL severity level causes
139 // the program to terminate (after the message is logged). 140 // the program to terminate (after the message is logged).
140 // 141 //
141 // There is the special severity of DFATAL, which logs FATAL in debug mode, 142 // There is the special severity of DFATAL, which logs FATAL in debug mode,
142 // ERROR in normal mode. 143 // ERROR in normal mode.
143 144
145 // Forward declaration of base::StringPiece for LogAssertHandlerFunction.
146 namespace base {
147 template <typename STRING_TYPE>
Paweł Hajdan Jr. 2017/03/13 15:49:50 For non-trivial types like StringPiece, I'd prefer
alex-ac 2017/03/14 10:23:14 base/strings/string_piece.h includes base/logging.
148 class BasicStringPiece;
149 typedef BasicStringPiece<std::string> StringPiece;
150 }
151
144 namespace logging { 152 namespace logging {
145 153
146 // TODO(avi): do we want to do a unification of character types here? 154 // TODO(avi): do we want to do a unification of character types here?
147 #if defined(OS_WIN) 155 #if defined(OS_WIN)
148 typedef wchar_t PathChar; 156 typedef wchar_t PathChar;
149 #else 157 #else
150 typedef char PathChar; 158 typedef char PathChar;
151 #endif 159 #endif
152 160
153 // Where to record logging output? A flat file and/or system debug log 161 // Where to record logging output? A flat file and/or system debug log
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // only. 275 // only.
268 BASE_EXPORT void SetLogItems(bool enable_process_id, bool enable_thread_id, 276 BASE_EXPORT void SetLogItems(bool enable_process_id, bool enable_thread_id,
269 bool enable_timestamp, bool enable_tickcount); 277 bool enable_timestamp, bool enable_tickcount);
270 278
271 // Sets whether or not you'd like to see fatal debug messages popped up in 279 // Sets whether or not you'd like to see fatal debug messages popped up in
272 // a dialog box or not. 280 // a dialog box or not.
273 // Dialogs are not shown by default. 281 // Dialogs are not shown by default.
274 BASE_EXPORT void SetShowErrorDialogs(bool enable_dialogs); 282 BASE_EXPORT void SetShowErrorDialogs(bool enable_dialogs);
275 283
276 // Sets the Log Assert Handler that will be used to notify of check failures. 284 // Sets the Log Assert Handler that will be used to notify of check failures.
285 // Resets Log Assert Handler on object destruction.
277 // The default handler shows a dialog box and then terminate the process, 286 // 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 287 // however clients can use this function to override with their own handling
279 // (e.g. a silent one for Unit Tests) 288 // (e.g. a silent one for Unit Tests)
280 typedef void (*LogAssertHandlerFunction)(const std::string& str); 289 typedef base::Callback<void(const char* file,
281 BASE_EXPORT void SetLogAssertHandler(LogAssertHandlerFunction handler); 290 int line,
291 const base::StringPiece& message,
292 const base::StringPiece& stack_trace)>
293 LogAssertHandlerFunction;
294
295 class BASE_EXPORT ScopedLogAssertHandler {
296 public:
297 explicit ScopedLogAssertHandler(LogAssertHandlerFunction handler);
298 ~ScopedLogAssertHandler();
299
300 private:
301 DISALLOW_COPY_AND_ASSIGN(ScopedLogAssertHandler);
302 };
282 303
283 // Sets the Log Message Handler that gets passed every log message before 304 // Sets the Log Message Handler that gets passed every log message before
284 // it's sent to other log destinations (if any). 305 // it's sent to other log destinations (if any).
285 // Returns true to signal that it handled the message and the message 306 // Returns true to signal that it handled the message and the message
286 // should not be sent to other log destinations. 307 // should not be sent to other log destinations.
287 typedef bool (*LogMessageHandlerFunction)(int severity, 308 typedef bool (*LogMessageHandlerFunction)(int severity,
288 const char* file, int line, size_t message_start, const std::string& str); 309 const char* file, int line, size_t message_start, const std::string& str);
289 BASE_EXPORT void SetLogMessageHandler(LogMessageHandlerFunction handler); 310 BASE_EXPORT void SetLogMessageHandler(LogMessageHandlerFunction handler);
290 BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler(); 311 BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler();
291 312
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 #elif NOTIMPLEMENTED_POLICY == 5 1039 #elif NOTIMPLEMENTED_POLICY == 5
1019 #define NOTIMPLEMENTED() do {\ 1040 #define NOTIMPLEMENTED() do {\
1020 static bool logged_once = false;\ 1041 static bool logged_once = false;\
1021 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1042 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1022 logged_once = true;\ 1043 logged_once = true;\
1023 } while(0);\ 1044 } while(0);\
1024 EAT_STREAM_PARAMETERS 1045 EAT_STREAM_PARAMETERS
1025 #endif 1046 #endif
1026 1047
1027 #endif // BASE_LOGGING_H_ 1048 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698