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 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 struct timespec tp = {0}; |
|
Mark Mentovai
2016/11/23 14:33:06
No need to initialize (same goes for local_time a
| |
| 769 clock_gettime(CLOCK_REALTIME, &tp); | |
|
Mark Mentovai
2016/11/23 14:33:06
Not available on WIndows! Take a look at how we so
Daniel Kurtz
2016/11/23 16:31:02
Any idea why mini_chromium already uses usec times
Daniel Kurtz
2016/11/24 03:09:53
Done.
| |
| 770 time_t t = tp.tv_sec; | |
| 769 struct tm local_time = {0}; | 771 struct tm local_time = {0}; |
| 770 #ifdef _MSC_VER | 772 #ifdef _MSC_VER |
| 771 localtime_s(&local_time, &t); | 773 localtime_s(&local_time, &t); |
| 772 #else | 774 #else |
| 773 localtime_r(&t, &local_time); | 775 localtime_r(&t, &local_time); |
| 774 #endif | 776 #endif |
| 775 struct tm* tm_time = &local_time; | 777 struct tm* tm_time = &local_time; |
| 776 stream_ << std::setfill('0') | 778 stream_ << std::setfill('0') |
| 777 << std::setw(2) << 1 + tm_time->tm_mon | 779 << std::setw(2) << 1 + tm_time->tm_mon |
| 778 << std::setw(2) << tm_time->tm_mday | 780 << std::setw(2) << tm_time->tm_mday |
| 779 << '/' | 781 << '/' |
| 780 << std::setw(2) << tm_time->tm_hour | 782 << std::setw(2) << tm_time->tm_hour |
| 781 << std::setw(2) << tm_time->tm_min | 783 << std::setw(2) << tm_time->tm_min |
| 782 << std::setw(2) << tm_time->tm_sec | 784 << std::setw(2) << tm_time->tm_sec |
| 785 << '.' | |
| 786 << std::setw(6) << (tp.tv_nsec / 1000) | |
| 783 << ':'; | 787 << ':'; |
| 784 } | 788 } |
| 785 if (g_log_tickcount) | 789 if (g_log_tickcount) |
| 786 stream_ << TickCount() << ':'; | 790 stream_ << TickCount() << ':'; |
| 787 if (severity_ >= 0) | 791 if (severity_ >= 0) |
| 788 stream_ << log_severity_name(severity_); | 792 stream_ << log_severity_name(severity_); |
| 789 else | 793 else |
| 790 stream_ << "VERBOSE" << -severity_; | 794 stream_ << "VERBOSE" << -severity_; |
| 791 | 795 |
| 792 stream_ << ":" << filename << "(" << line << ")] "; | 796 stream_ << ":" << filename << "(" << line << ")] "; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { | 925 BASE_EXPORT void LogErrorNotReached(const char* file, int line) { |
| 922 LogMessage(file, line, LOG_ERROR).stream() | 926 LogMessage(file, line, LOG_ERROR).stream() |
| 923 << "NOTREACHED() hit."; | 927 << "NOTREACHED() hit."; |
| 924 } | 928 } |
| 925 | 929 |
| 926 } // namespace logging | 930 } // namespace logging |
| 927 | 931 |
| 928 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { | 932 std::ostream& std::operator<<(std::ostream& out, const wchar_t* wstr) { |
| 929 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); | 933 return out << (wstr ? base::WideToUTF8(wstr) : std::string()); |
| 930 } | 934 } |
| OLD | NEW |