Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 typedef pthread_mutex_t* MutexHandle; | 46 typedef pthread_mutex_t* MutexHandle; |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #include <algorithm> | 49 #include <algorithm> |
| 50 #include <cstring> | 50 #include <cstring> |
| 51 #include <ctime> | 51 #include <ctime> |
| 52 #include <iomanip> | 52 #include <iomanip> |
| 53 #include <ostream> | 53 #include <ostream> |
| 54 #include <string> | 54 #include <string> |
| 55 | 55 |
| 56 #include "base/auto_reset.h" | |
| 56 #include "base/base_switches.h" | 57 #include "base/base_switches.h" |
| 57 #include "base/command_line.h" | 58 #include "base/command_line.h" |
| 58 #include "base/debug/alias.h" | 59 #include "base/debug/alias.h" |
| 60 #include "base/debug/crash_logging.h" | |
| 59 #include "base/debug/debugger.h" | 61 #include "base/debug/debugger.h" |
| 60 #include "base/debug/stack_trace.h" | 62 #include "base/debug/stack_trace.h" |
| 61 #include "base/posix/eintr_wrapper.h" | 63 #include "base/posix/eintr_wrapper.h" |
| 62 #include "base/strings/string_piece.h" | 64 #include "base/strings/string_piece.h" |
| 63 #include "base/strings/string_util.h" | 65 #include "base/strings/string_util.h" |
| 64 #include "base/strings/stringprintf.h" | 66 #include "base/strings/stringprintf.h" |
| 65 #include "base/strings/sys_string_conversions.h" | 67 #include "base/strings/sys_string_conversions.h" |
| 66 #include "base/strings/utf_string_conversions.h" | 68 #include "base/strings/utf_string_conversions.h" |
| 67 #include "base/synchronization/lock_impl.h" | 69 #include "base/synchronization/lock_impl.h" |
| 68 #include "base/threading/platform_thread.h" | 70 #include "base/threading/platform_thread.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { | 532 if (severity_ == LOG_FATAL && !base::debug::BeingDebugged()) { |
| 531 // Include a stack trace on a fatal, unless a debugger is attached. | 533 // Include a stack trace on a fatal, unless a debugger is attached. |
| 532 base::debug::StackTrace trace; | 534 base::debug::StackTrace trace; |
| 533 stream_ << std::endl; // Newline to separate from log message. | 535 stream_ << std::endl; // Newline to separate from log message. |
| 534 trace.OutputToStream(&stream_); | 536 trace.OutputToStream(&stream_); |
| 535 } | 537 } |
| 536 #endif | 538 #endif |
| 537 stream_ << std::endl; | 539 stream_ << std::endl; |
| 538 std::string str_newline(stream_.str()); | 540 std::string str_newline(stream_.str()); |
| 539 | 541 |
| 542 // NaCl targets do not have base/debug/crash_logging.cc. | |
| 543 #if !defined(OS_NACL) | |
| 544 if (severity_ == LOG_FATAL) { | |
|
dcheng
2016/10/06 08:52:40
This still needs to protect against reentrancy, un
rkuksin
2016/10/07 07:44:12
Done.
| |
| 545 base::debug::SetCrashKeyValue( | |
| 546 "LOG_FATAL", base::StringPiece(str_newline.c_str() + message_start_)); | |
| 547 } | |
| 548 #endif // !defined(OS_NACL) | |
| 549 | |
| 540 // Give any log message handler first dibs on the message. | 550 // Give any log message handler first dibs on the message. |
| 541 if (log_message_handler && | 551 if (log_message_handler && |
| 542 log_message_handler(severity_, file_, line_, | 552 log_message_handler(severity_, file_, line_, |
| 543 message_start_, str_newline)) { | 553 message_start_, str_newline)) { |
| 544 // The handler took care of it, no further processing. | 554 // The handler took care of it, no further processing. |
| 545 return; | 555 return; |
| 546 } | 556 } |
| 547 | 557 |
| 548 if ((g_logging_destination & LOG_TO_SYSTEM_DEBUG_LOG) != 0) { | 558 if ((g_logging_destination & LOG_TO_SYSTEM_DEBUG_LOG) != 0) { |
| 549 #if defined(OS_WIN) | 559 #if defined(OS_WIN) |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 931 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 922 LogMessage(file, line, LOG_ERROR).stream() | 932 LogMessage(file, line, LOG_ERROR).stream() |
| 923 << "NOTREACHED() hit."; | 933 << "NOTREACHED() hit."; |
| 924 } | 934 } |
| 925 | 935 |
| 926 } // namespace logging | 936 } // namespace logging |
| 927 | 937 |
| 928 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 938 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 929 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 939 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
| 930 } | 940 } |
| OLD | NEW |