| 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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 filename.remove_prefix(last_slash_pos + 1); | 758 filename.remove_prefix(last_slash_pos + 1); |
| 759 | 759 |
| 760 // TODO(darin): It might be nice if the columns were fixed width. | 760 // TODO(darin): It might be nice if the columns were fixed width. |
| 761 | 761 |
| 762 stream_ << '['; | 762 stream_ << '['; |
| 763 if (g_log_process_id) | 763 if (g_log_process_id) |
| 764 stream_ << CurrentProcessId() << ':'; | 764 stream_ << CurrentProcessId() << ':'; |
| 765 if (g_log_thread_id) | 765 if (g_log_thread_id) |
| 766 stream_ << base::PlatformThread::CurrentId() << ':'; | 766 stream_ << base::PlatformThread::CurrentId() << ':'; |
| 767 if (g_log_timestamp) { | 767 if (g_log_timestamp) { |
| 768 time_t t = time(nullptr); | 768 #if defined(OS_POSIX) |
| 769 struct tm local_time = {0}; | 769 timeval tv; |
| 770 #ifdef _MSC_VER | 770 gettimeofday(&tv, nullptr); |
| 771 localtime_s(&local_time, &t); | 771 time_t t = tv.tv_sec; |
| 772 #else | 772 struct tm local_time; |
| 773 localtime_r(&t, &local_time); | 773 localtime_r(&t, &local_time); |
| 774 #endif | |
| 775 struct tm* tm_time = &local_time; | 774 struct tm* tm_time = &local_time; |
| 776 stream_ << std::setfill('0') | 775 stream_ << std::setfill('0') |
| 777 << std::setw(2) << 1 + tm_time->tm_mon | 776 << std::setw(2) << 1 + tm_time->tm_mon |
| 778 << std::setw(2) << tm_time->tm_mday | 777 << std::setw(2) << tm_time->tm_mday |
| 779 << '/' | 778 << '/' |
| 780 << std::setw(2) << tm_time->tm_hour | 779 << std::setw(2) << tm_time->tm_hour |
| 781 << std::setw(2) << tm_time->tm_min | 780 << std::setw(2) << tm_time->tm_min |
| 782 << std::setw(2) << tm_time->tm_sec | 781 << std::setw(2) << tm_time->tm_sec |
| 782 << '.' |
| 783 << std::setw(6) << tv.tv_usec |
| 783 << ':'; | 784 << ':'; |
| 785 #elif defined(OS_WIN) |
| 786 SYSTEMTIME local_time; |
| 787 GetLocalTime(&local_time); |
| 788 stream_ << std::setfill('0') |
| 789 << std::setw(2) << local_time.wMonth |
| 790 << std::setw(2) << local_time.wDay |
| 791 << '/' |
| 792 << std::setw(2) << local_time.wHour |
| 793 << std::setw(2) << local_time.wMinute |
| 794 << std::setw(2) << local_time.wSecond |
| 795 << '.' |
| 796 << std::setw(3) << local_time.wMilliseconds |
| 797 << ':'; |
| 798 #endif |
| 784 } | 799 } |
| 785 if (g_log_tickcount) | 800 if (g_log_tickcount) |
| 786 stream_ << TickCount() << ':'; | 801 stream_ << TickCount() << ':'; |
| 787 if (severity_ >= 0) | 802 if (severity_ >= 0) |
| 788 stream_ << log_severity_name(severity_); | 803 stream_ << log_severity_name(severity_); |
| 789 else | 804 else |
| 790 stream_ << "VERBOSE" << -severity_; | 805 stream_ << "VERBOSE" << -severity_; |
| 791 | 806 |
| 792 stream_ << ":" << filename << "(" << line << ")] "; | 807 stream_ << ":" << filename << "(" << line << ")] "; |
| 793 | 808 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 936 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 922 LogMessage(file, line, LOG_ERROR).stream() | 937 LogMessage(file, line, LOG_ERROR).stream() |
| 923 << "NOTREACHED() hit."; | 938 << "NOTREACHED() hit."; |
| 924 } | 939 } |
| 925 | 940 |
| 926 } // namespace logging | 941 } // namespace logging |
| 927 | 942 |
| 928 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 943 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 929 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 944 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
| 930 } | 945 } |
| OLD | NEW |