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

Unified Diff: base/logging.h

Issue 21216: Change the behavior of --enable-dcheck from crashing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/logging.cc » ('j') | base/logging.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.h
===================================================================
--- base/logging.h (revision 9544)
+++ base/logging.h (working copy)
@@ -77,13 +77,18 @@
// We also override the standard 'assert' to use 'DLOG_ASSERT'.
//
// The supported severity levels for macros that allow you to specify one
-// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
+// are (in increasing order of severity) INFO, WARNING, ERROR, ERROR_REPORT,
+// and FATAL.
//
-// There is also the special severity of DFATAL, which logs FATAL in
-// debug mode, ERROR in normal mode.
-//
// Very important: logging a message at the FATAL severity level causes
// the program to terminate (after the message is logged).
+//
+// Note the special severity of ERROR_REPORT only available/relevant in normal
wtc 2009/02/19 01:32:04 Nit: add "is" before "available/relevant".
+// mode, which displays error dialog without terminating the program. There is
wtc 2009/02/19 01:32:04 Nit: add "an" before "error dialog".
+// no error dialog for severity ERROR or below in normal mode.
+//
+// There is also the special severity of DFATAL, which logs FATAL in
+// debug mode, ERROR_REPORT in normal mode.
namespace logging {
@@ -151,22 +156,29 @@
bool enable_timestamp, bool enable_tickcount);
// Sets the Log Assert Handler that will be used to notify of check failures.
-// The default handler shows a dialog box, however clients can use this
-// function to override with their own handling (e.g. a silent one for Unit
-// Tests)
+// The default handler shows a dialog box and then terminate the process,
wtc 2009/02/19 01:32:04 Nit: "terminate" => "terminates"
+// however clients can use this function to override with their own handling
+// (e.g. a silent one for Unit Tests)
typedef void (*LogAssertHandlerFunction)(const std::string& str);
void SetLogAssertHandler(LogAssertHandlerFunction handler);
+// Sets the Log Report Handler that will be used to notify of check failures
wtc 2009/02/19 01:32:04 Nit: add a blank line above this line.
+// in non-debug mode. The default handler shows a dialog box and continues
+// the execution, however clients can use this function to override with their
+// own handling.
+typedef void (*LogReportHandlerFunction)(const std::string& str);
+void SetLogReportHandler(LogReportHandlerFunction handler);
typedef int LogSeverity;
const LogSeverity LOG_INFO = 0;
const LogSeverity LOG_WARNING = 1;
const LogSeverity LOG_ERROR = 2;
-const LogSeverity LOG_FATAL = 3;
-const LogSeverity LOG_NUM_SEVERITIES = 4;
+const LogSeverity LOG_ERROR_REPORT = 3;
+const LogSeverity LOG_FATAL = 4;
+const LogSeverity LOG_NUM_SEVERITIES = 5;
-// LOG_DFATAL_LEVEL is LOG_FATAL in debug mode, ERROR in normal mode
+// LOG_DFATAL_LEVEL is LOG_FATAL in debug mode, ERROR_REPORT in normal mode
#ifdef NDEBUG
-const LogSeverity LOG_DFATAL_LEVEL = LOG_ERROR;
+const LogSeverity LOG_DFATAL_LEVEL = LOG_ERROR_REPORT;
#else
const LogSeverity LOG_DFATAL_LEVEL = LOG_FATAL;
#endif
@@ -180,6 +192,8 @@
logging::LogMessage(__FILE__, __LINE__, logging::LOG_WARNING)
#define COMPACT_GOOGLE_LOG_ERROR \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR)
+#define COMPACT_GOOGLE_LOG_ERROR_REPORT \
+ logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR_REPORT)
#define COMPACT_GOOGLE_LOG_FATAL \
logging::LogMessage(__FILE__, __LINE__, logging::LOG_FATAL)
#define COMPACT_GOOGLE_LOG_DFATAL \
@@ -395,7 +409,7 @@
extern bool g_enable_dcheck;
#define DCHECK(condition) \
!logging::g_enable_dcheck ? void (0) : \
- LOG_IF(FATAL, !(condition)) << "Check failed: " #condition ". "
+ LOG_IF(ERROR_REPORT, !(condition)) << "Check failed: " #condition ". "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
@@ -403,7 +417,8 @@
if (logging::g_enable_dcheck) \
if (logging::CheckOpString _result = \
logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2)) \
- logging::LogMessage(__FILE__, __LINE__, _result).stream()
+ logging::LogMessage(__FILE__, __LINE__, logging::LOG_ERROR_REPORT, \
+ _result).stream()
#define DCHECK_STREQ(str1, str2) \
while (false) NDEBUG_EAT_STREAM_PARAMETERS
@@ -508,6 +523,11 @@
// Implied severity = LOG_FATAL
LogMessage(const char* file, int line, const CheckOpString& result);
+ // A special constructor used for check failures, with the option to
+ // specify severity.
+ LogMessage(const char* file, int line, LogSeverity severity,
+ const CheckOpString& result);
+
~LogMessage();
std::ostream& stream() { return stream_; }
« no previous file with comments | « no previous file | base/logging.cc » ('j') | base/logging.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698