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

Side by Side Diff: base/logging.h

Issue 2288473002: Implement Dump-on-DCHECK (via a new LogSeverity). (Closed)
Patch Set: Migrate some tests to EXPECT_DCHECK_DEATH Created 4 years 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
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>
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler(); 289 BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler();
290 290
291 typedef int LogSeverity; 291 typedef int LogSeverity;
292 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity 292 const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity
293 // Note: the log severities are used to index into the array of names, 293 // Note: the log severities are used to index into the array of names,
294 // see log_severity_names. 294 // see log_severity_names.
295 const LogSeverity LOG_INFO = 0; 295 const LogSeverity LOG_INFO = 0;
296 const LogSeverity LOG_WARNING = 1; 296 const LogSeverity LOG_WARNING = 1;
297 const LogSeverity LOG_ERROR = 2; 297 const LogSeverity LOG_ERROR = 2;
298 const LogSeverity LOG_FATAL = 3; 298 const LogSeverity LOG_FATAL = 3;
299 const LogSeverity LOG_NUM_SEVERITIES = 4; 299 const LogSeverity LOG_DUMP = 4;
300 const LogSeverity LOG_NUM_SEVERITIES = 5;
Wez 2016/12/19 23:57:46 Q: Is changing the number of severities acceptable
300 301
301 // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode 302 // LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode
302 #ifdef NDEBUG 303 #ifdef NDEBUG
303 const LogSeverity LOG_DFATAL = LOG_ERROR; 304 const LogSeverity LOG_DFATAL = LOG_ERROR;
305 #elif defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
306 const LogSeverity LOG_DFATAL = LOG_DUMP;
304 #else 307 #else
305 const LogSeverity LOG_DFATAL = LOG_FATAL; 308 const LogSeverity LOG_DFATAL = LOG_FATAL;
306 #endif 309 #endif
307 310
308 // A few definitions of macros that don't generate much code. These are used 311 // A few definitions of macros that don't generate much code. These are used
309 // by LOG() and LOG_IF, etc. Since these are used all over our code, it's 312 // by LOG() and LOG_IF, etc. Since these are used all over our code, it's
310 // better to have compact code for these operations. 313 // better to have compact code for these operations.
311 #define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ 314 #define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
312 ::logging::ClassName(__FILE__, __LINE__, ::logging::LOG_INFO, ##__VA_ARGS__) 315 ::logging::ClassName(__FILE__, __LINE__, ::logging::LOG_INFO, ##__VA_ARGS__)
313 #define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ 316 #define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 689
687 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 690 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
688 691
689 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 692 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
690 693
691 // Definitions for DCHECK et al. 694 // Definitions for DCHECK et al.
692 695
693 #if DCHECK_IS_ON() 696 #if DCHECK_IS_ON()
694 697
695 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 698 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
696 COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) 699 COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ##__VA_ARGS__)
697 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL 700 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_DFATAL
698 const LogSeverity LOG_DCHECK = LOG_FATAL; 701 const LogSeverity LOG_DCHECK = LOG_DFATAL;
699 702
700 #else // DCHECK_IS_ON() 703 #else // DCHECK_IS_ON()
701 704
702 // These are just dummy values. 705 // These are just dummy values.
703 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 706 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
704 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) 707 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__)
705 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO 708 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
706 const LogSeverity LOG_DCHECK = LOG_INFO; 709 const LogSeverity LOG_DCHECK = LOG_INFO;
707 710
708 #endif // DCHECK_IS_ON() 711 #endif // DCHECK_IS_ON()
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 #elif NOTIMPLEMENTED_POLICY == 5 1020 #elif NOTIMPLEMENTED_POLICY == 5
1018 #define NOTIMPLEMENTED() do {\ 1021 #define NOTIMPLEMENTED() do {\
1019 static bool logged_once = false;\ 1022 static bool logged_once = false;\
1020 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1023 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1021 logged_once = true;\ 1024 logged_once = true;\
1022 } while(0);\ 1025 } while(0);\
1023 EAT_STREAM_PARAMETERS 1026 EAT_STREAM_PARAMETERS
1024 #endif 1027 #endif
1025 1028
1026 #endif // BASE_LOGGING_H_ 1029 #endif // BASE_LOGGING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698