From d1ccc35a971671602f4b6745ae76d814fa08b144 Mon Sep 17 00:00:00 2001 From: "oshima@chromium.org" Date: Wed, 24 Mar 2010 05:03:24 +0000 Subject: print stack trace to stderr as well as to dialog. Stacktrace info was shown only in dialog, and chromeos was not getting this as it does not have xmessage. Changed to include stacktrace to the log message before being printed to stderr. BUG=none TEST=none Review URL: http://codereview.chromium.org/1094012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42431 0039d316-1c4b-4281-b951-d872f2087c98 --- base/logging.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'base') diff --git a/base/logging.cc b/base/logging.cc index fa98eb2..851bdcc 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -458,12 +458,17 @@ LogMessage::~LogMessage() { if (severity_ < min_log_level) return; - std::string str_newline(stream_.str()); -#if defined(OS_WIN) - str_newline.append("\r\n"); -#else - str_newline.append("\n"); +#ifndef NDEBUG + if (severity_ == LOG_FATAL) { + // Include a stack trace on a fatal. + StackTrace trace; + stream_ << std::endl; // Newline to separate from log message. + trace.OutputToStream(&stream_); + } #endif + stream_ << std::endl; + std::string str_newline(stream_.str()); + // Give any log message handler first dibs on the message. if (log_message_handler && log_message_handler(severity_, str_newline)) return; @@ -565,13 +570,6 @@ LogMessage::~LogMessage() { if (DebugUtil::BeingDebugged()) { DebugUtil::BreakDebugger(); } else { -#ifndef NDEBUG - // Dump a stack trace on a fatal. - StackTrace trace; - stream_ << "\n"; // Newline to separate from log message. - trace.OutputToStream(&stream_); -#endif - if (log_assert_handler) { // make a copy of the string for the handler out of paranoia log_assert_handler(std::string(stream_.str())); -- cgit v1.1