| 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 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 nullptr); | 715 nullptr); |
| 716 #else | 716 #else |
| 717 ignore_result(fwrite( | 717 ignore_result(fwrite( |
| 718 str_newline.data(), str_newline.size(), 1, g_log_file)); | 718 str_newline.data(), str_newline.size(), 1, g_log_file)); |
| 719 fflush(g_log_file); | 719 fflush(g_log_file); |
| 720 #endif | 720 #endif |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 | 723 |
| 724 if (severity_ == LOG_FATAL) { | 724 if (severity_ == LOG_FATAL) { |
| 725 fprintf(stderr, "FATAL\n"); |
| 726 fflush(stderr); |
| 727 |
| 725 // Ensure the first characters of the string are on the stack so they | 728 // Ensure the first characters of the string are on the stack so they |
| 726 // are contained in minidumps for diagnostic purposes. | 729 // are contained in minidumps for diagnostic purposes. |
| 727 char str_stack[1024]; | 730 char str_stack[1024]; |
| 728 str_newline.copy(str_stack, arraysize(str_stack)); | 731 str_newline.copy(str_stack, arraysize(str_stack)); |
| 729 base::debug::Alias(str_stack); | 732 base::debug::Alias(str_stack); |
| 730 | 733 |
| 731 if (log_assert_handler) { | 734 if (log_assert_handler) { |
| 732 // Make a copy of the string for the handler out of paranoia. | 735 // Make a copy of the string for the handler out of paranoia. |
| 733 log_assert_handler(std::string(stream_.str())); | 736 log_assert_handler(std::string(stream_.str())); |
| 737 fprintf(stderr, "log_assert_handler\n"); |
| 738 fflush(stderr); |
| 734 } else { | 739 } else { |
| 735 // Don't use the string with the newline, get a fresh version to send to | 740 // Don't use the string with the newline, get a fresh version to send to |
| 736 // the debug message process. We also don't display assertions to the | 741 // the debug message process. We also don't display assertions to the |
| 737 // user in release mode. The enduser can't do anything with this | 742 // user in release mode. The enduser can't do anything with this |
| 738 // information, and displaying message boxes when the application is | 743 // information, and displaying message boxes when the application is |
| 739 // hosed can cause additional problems. | 744 // hosed can cause additional problems. |
| 740 #ifndef NDEBUG | 745 #ifndef NDEBUG |
| 741 if (!base::debug::BeingDebugged()) { | 746 if (!base::debug::BeingDebugged()) { |
| 742 // Displaying a dialog is unnecessary when debugging and can complicate | 747 // Displaying a dialog is unnecessary when debugging and can complicate |
| 743 // debugging. | 748 // debugging. |
| 744 DisplayDebugMessageInDialog(stream_.str()); | 749 DisplayDebugMessageInDialog(stream_.str()); |
| 745 } | 750 } |
| 746 #endif | 751 #endif |
| 747 // Crash the process to generate a dump. | 752 // Crash the process to generate a dump. |
| 753 fprintf(stderr, "Call BreakDebugger\n"); |
| 754 fflush(stderr); |
| 748 base::debug::BreakDebugger(); | 755 base::debug::BreakDebugger(); |
| 749 } | 756 } |
| 750 } | 757 } |
| 751 } | 758 } |
| 752 | 759 |
| 753 // writes the common header info to the stream | 760 // writes the common header info to the stream |
| 754 void LogMessage::Init(const char* file, int line) { | 761 void LogMessage::Init(const char* file, int line) { |
| 755 base::StringPiece filename(file); | 762 base::StringPiece filename(file); |
| 756 size_t last_slash_pos = filename.find_last_of("\\/"); | 763 size_t last_slash_pos = filename.find_last_of("\\/"); |
| 757 if (last_slash_pos != base::StringPiece::npos) | 764 if (last_slash_pos != base::StringPiece::npos) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 928 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 922 LogMessage(file, line, LOG_ERROR).stream() | 929 LogMessage(file, line, LOG_ERROR).stream() |
| 923 << "NOTREACHED() hit."; | 930 << "NOTREACHED() hit."; |
| 924 } | 931 } |
| 925 | 932 |
| 926 } // namespace logging | 933 } // namespace logging |
| 927 | 934 |
| 928 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 935 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 929 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 936 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
| 930 } | 937 } |
| OLD | NEW |