diff options
author | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 01:19:05 +0000 |
---|---|---|
committer | huanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 01:19:05 +0000 |
commit | fb62a5370cdd2626eae72bb8ba883287b28e830c (patch) | |
tree | e85fe192ebddb13670a81967905b5e4964549233 /base/logging.cc | |
parent | bd580a2503917df061b20b1948297650344b931f (diff) | |
download | chromium_src-fb62a5370cdd2626eae72bb8ba883287b28e830c.zip chromium_src-fb62a5370cdd2626eae72bb8ba883287b28e830c.tar.gz chromium_src-fb62a5370cdd2626eae72bb8ba883287b28e830c.tar.bz2 |
Change the behavior of --enable-dcheck in release
build from crashing to logging the failure and
continuing. In addition,
- In interactive mode, we will display a message
box so the user can either click OK and continue
or attach a debugger.
- If Chrome is running in test environment, it
has the option to overide the default behavior
and suppress the error dialog.
To support this, a new severity level ERROR_REPORT
is added.
In addition, DFATAL is now mapped to ERROR_REPORT
instead of ERROR. The only usage of DFATAL is in
ssl_client_socket_nss.cc. Add wtc for code review.
Review URL: http://codereview.chromium.org/21216
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.cc')
-rw-r--r-- | base/logging.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/base/logging.cc b/base/logging.cc index cc9c7db..4daefcd 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -46,7 +46,7 @@ namespace logging { bool g_enable_dcheck = false; const char* const log_severity_names[LOG_NUM_SEVERITIES] = { - "INFO", "WARNING", "ERROR", "FATAL" }; + "INFO", "WARNING", "ERROR", "ERROR_REPORT", "FATAL" }; int min_log_level = 0; LogLockingState lock_log_file = LOCK_LOG_FILE; @@ -89,8 +89,11 @@ bool log_timestamp = true; bool log_tickcount = false; // An assert handler override specified by the client to be called instead of -// the debug message dialog. +// the debug message dialog and process termination. LogAssertHandlerFunction log_assert_handler = NULL; +// An report handler override specified by the client to be called instead of +// the debug message dialog. +LogReportHandlerFunction log_report_handler = NULL; // The lock is used if log file locking is false. It helps us avoid problems // with multiple threads writing to the log file at the same time. Use @@ -291,6 +294,10 @@ void SetLogAssertHandler(LogAssertHandlerFunction handler) { log_assert_handler = handler; } +void SetLogReportHandler(LogReportHandlerFunction handler) { + log_report_handler = handler; +} + // Displays a message box to the user with the error message in it. For // Windows programs, it's possible that the message loop is messed up on // a fatal error, and creating a MessageBox will cause that message loop @@ -348,6 +355,13 @@ LogMessage::LogMessage(const char* file, int line, const CheckOpString& result) stream_ << "Check failed: " << (*result.str_); } +LogMessage::LogMessage(const char* file, int line, LogSeverity severity, + const CheckOpString& result) + : severity_(severity) { + Init(file, line); + stream_ << "Check failed: " << (*result.str_); +} + LogMessage::LogMessage(const char* file, int line) : severity_(LOG_INFO) { Init(file, line); @@ -511,6 +525,13 @@ LogMessage::~LogMessage() { // dump, but until then, do not invoke the Apple crash reporter. } } + } else if (severity_ == LOG_ERROR_REPORT) { + // We are here only if the user runs with --enable-dcheck in release mode. + if (log_report_handler) { + log_report_handler(std::string(stream_.str())); + } else { + DisplayDebugMessage(stream_.str()); + } } } |