| Index: base/logging.cc
|
| diff --git a/base/logging.cc b/base/logging.cc
|
| index 0771b47c182e5c18c868f1124a0784bf411d74a9..e0ca19933e75d546cb18c755c0f8024b23de776d 100644
|
| --- a/base/logging.cc
|
| +++ b/base/logging.cc
|
| @@ -765,13 +765,12 @@ void LogMessage::Init(const char* file, int line) {
|
| if (g_log_thread_id)
|
| stream_ << base::PlatformThread::CurrentId() << ':';
|
| if (g_log_timestamp) {
|
| - time_t t = time(nullptr);
|
| - struct tm local_time = {0};
|
| -#ifdef _MSC_VER
|
| - localtime_s(&local_time, &t);
|
| -#else
|
| +#if defined(OS_POSIX)
|
| + timeval tv;
|
| + gettimeofday(&tv, nullptr);
|
| + time_t t = tv.tv_sec;
|
| + struct tm local_time;
|
| localtime_r(&t, &local_time);
|
| -#endif
|
| struct tm* tm_time = &local_time;
|
| stream_ << std::setfill('0')
|
| << std::setw(2) << 1 + tm_time->tm_mon
|
| @@ -780,7 +779,23 @@ void LogMessage::Init(const char* file, int line) {
|
| << std::setw(2) << tm_time->tm_hour
|
| << std::setw(2) << tm_time->tm_min
|
| << std::setw(2) << tm_time->tm_sec
|
| + << '.'
|
| + << std::setw(6) << tv.tv_usec
|
| << ':';
|
| +#elif defined(OS_WIN)
|
| + SYSTEMTIME local_time;
|
| + GetLocalTime(&local_time);
|
| + stream_ << std::setfill('0')
|
| + << std::setw(2) << local_time.wMonth
|
| + << std::setw(2) << local_time.wDay
|
| + << '/'
|
| + << std::setw(2) << local_time.wHour
|
| + << std::setw(2) << local_time.wMinute
|
| + << std::setw(2) << local_time.wSecond
|
| + << '.'
|
| + << std::setw(3) << local_time.wMilliseconds
|
| + << ':';
|
| +#endif
|
| }
|
| if (g_log_tickcount)
|
| stream_ << TickCount() << ':';
|
|
|