| 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/debug/activity_tracker.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 | 13 |
| 13 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 14 #include <io.h> | 15 #include <io.h> |
| 15 #include <windows.h> | 16 #include <windows.h> |
| 16 typedef HANDLE FileHandle; | 17 typedef HANDLE FileHandle; |
| 17 typedef HANDLE MutexHandle; | 18 typedef HANDLE MutexHandle; |
| 18 // Windows warns on using write(). It prefers _write(). | 19 // Windows warns on using write(). It prefers _write(). |
| 19 #define write(fd, buf, count) _write(fd, buf, static_cast<unsigned int>(count)) | 20 #define write(fd, buf, count) _write(fd, buf, static_cast<unsigned int>(count)) |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 nullptr); | 716 nullptr); |
| 716 #else | 717 #else |
| 717 ignore_result(fwrite( | 718 ignore_result(fwrite( |
| 718 str_newline.data(), str_newline.size(), 1, g_log_file)); | 719 str_newline.data(), str_newline.size(), 1, g_log_file)); |
| 719 fflush(g_log_file); | 720 fflush(g_log_file); |
| 720 #endif | 721 #endif |
| 721 } | 722 } |
| 722 } | 723 } |
| 723 | 724 |
| 724 if (severity_ == LOG_FATAL) { | 725 if (severity_ == LOG_FATAL) { |
| 726 // Write the log message to the global activity tracker, if running. |
| 727 base::debug::GlobalActivityTracker* tracker = |
| 728 base::debug::GlobalActivityTracker::Get(); |
| 729 if (tracker) |
| 730 tracker->RecordLogMessage(str_newline); |
| 731 |
| 725 // Ensure the first characters of the string are on the stack so they | 732 // Ensure the first characters of the string are on the stack so they |
| 726 // are contained in minidumps for diagnostic purposes. | 733 // are contained in minidumps for diagnostic purposes. |
| 727 char str_stack[1024]; | 734 char str_stack[1024]; |
| 728 str_newline.copy(str_stack, arraysize(str_stack)); | 735 str_newline.copy(str_stack, arraysize(str_stack)); |
| 729 base::debug::Alias(str_stack); | 736 base::debug::Alias(str_stack); |
| 730 | 737 |
| 731 if (log_assert_handler) { | 738 if (log_assert_handler) { |
| 732 // Make a copy of the string for the handler out of paranoia. | 739 // Make a copy of the string for the handler out of paranoia. |
| 733 log_assert_handler(std::string(stream_.str())); | 740 log_assert_handler(std::string(stream_.str())); |
| 734 } else { | 741 } else { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 943 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 937 LogMessage(file, line, LOG_ERROR).stream() | 944 LogMessage(file, line, LOG_ERROR).stream() |
| 938 << "NOTREACHED() hit."; | 945 << "NOTREACHED() hit."; |
| 939 } | 946 } |
| 940 | 947 |
| 941 } // namespace logging | 948 } // namespace logging |
| 942 | 949 |
| 943 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 950 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 944 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 951 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
| 945 } | 952 } |
| OLD | NEW |