OLD | NEW |
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 #include "base/logging.h" | 5 #include "base/logging.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <io.h> | 8 #include <io.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 typedef HANDLE FileHandle; | 10 typedef HANDLE FileHandle; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 LogMessage::LogMessage(const char* file, int line, LogSeverity severity, | 537 LogMessage::LogMessage(const char* file, int line, LogSeverity severity, |
538 std::string* result) | 538 std::string* result) |
539 : severity_(severity), file_(file), line_(line) { | 539 : severity_(severity), file_(file), line_(line) { |
540 Init(file, line); | 540 Init(file, line); |
541 stream_ << "Check failed: " << *result; | 541 stream_ << "Check failed: " << *result; |
542 delete result; | 542 delete result; |
543 } | 543 } |
544 | 544 |
545 LogMessage::~LogMessage() { | 545 LogMessage::~LogMessage() { |
546 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) | 546 #if !defined(OFFICIAL_BUILD) && !defined(OS_NACL) && !defined(__UCLIBC__) |
547 if (severity_ == LOG_FATAL) { | 547 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { |
548 // Include a stack trace on a fatal. | 548 // Include a stack trace on a fatal, unless a debugger is attached. |
549 base::debug::StackTrace trace; | 549 base::debug::StackTrace trace; |
550 stream_ << std::endl; // Newline to separate from log message. | 550 stream_ << std::endl; // Newline to separate from log message. |
551 trace.OutputToStream(&stream_); | 551 trace.OutputToStream(&stream_); |
552 } | 552 } |
553 #endif | 553 #endif |
554 stream_ << std::endl; | 554 stream_ << std::endl; |
555 std::string str_newline(stream_.str()); | 555 std::string str_newline(stream_.str()); |
556 | 556 |
557 // Give any log message handler first dibs on the message. | 557 // Give any log message handler first dibs on the message. |
558 if (log_message_handler && | 558 if (log_message_handler && |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 if (log_assert_handler) { | 632 if (log_assert_handler) { |
633 // Make a copy of the string for the handler out of paranoia. | 633 // Make a copy of the string for the handler out of paranoia. |
634 log_assert_handler(std::string(stream_.str())); | 634 log_assert_handler(std::string(stream_.str())); |
635 } else { | 635 } else { |
636 // Don't use the string with the newline, get a fresh version to send to | 636 // Don't use the string with the newline, get a fresh version to send to |
637 // the debug message process. We also don't display assertions to the | 637 // the debug message process. We also don't display assertions to the |
638 // user in release mode. The enduser can't do anything with this | 638 // user in release mode. The enduser can't do anything with this |
639 // information, and displaying message boxes when the application is | 639 // information, and displaying message boxes when the application is |
640 // hosed can cause additional problems. | 640 // hosed can cause additional problems. |
641 #ifndef NDEBUG | 641 #ifndef NDEBUG |
642 DisplayDebugMessageInDialog(stream_.str()); | 642 if (!base::debug::BeingDebugged()) { |
| 643 // Displaying a dialog is unnecessary when debugging and can complicate |
| 644 // debugging. |
| 645 DisplayDebugMessageInDialog(stream_.str()); |
| 646 } |
643 #endif | 647 #endif |
644 // Crash the process to generate a dump. | 648 // Crash the process to generate a dump. |
645 base::debug::BreakDebugger(); | 649 base::debug::BreakDebugger(); |
646 } | 650 } |
647 } | 651 } |
648 } | 652 } |
649 | 653 |
650 // writes the common header info to the stream | 654 // writes the common header info to the stream |
651 void LogMessage::Init(const char* file, int line) { | 655 void LogMessage::Init(const char* file, int line) { |
652 base::StringPiece filename(file); | 656 base::StringPiece filename(file); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 816 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
813 LogMessage(file, line, LOG_ERROR).stream() | 817 LogMessage(file, line, LOG_ERROR).stream() |
814 << "NOTREACHED() hit."; | 818 << "NOTREACHED() hit."; |
815 } | 819 } |
816 | 820 |
817 } // namespace logging | 821 } // namespace logging |
818 | 822 |
819 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 823 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
820 return out << base::WideToUTF8(wstr); | 824 return out << base::WideToUTF8(wstr); |
821 } | 825 } |
OLD | NEW |