Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: base/logging.cc

Issue 2528613002: base: Print sub-second resolution timestamps (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.cc
diff --git a/base/logging.cc b/base/logging.cc
index 0771b47c182e5c18c868f1124a0784bf411d74a9..5b27507b9572ffb97cd660454644d345e3595ff7 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -765,7 +765,9 @@ 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 timespec tp = {0};
Mark Mentovai 2016/11/23 14:33:06 No need to initialize (same goes for local_time a
+ 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.
+ time_t t = tp.tv_sec;
struct tm local_time = {0};
#ifdef _MSC_VER
localtime_s(&local_time, &t);
@@ -780,6 +782,8 @@ 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) << (tp.tv_nsec / 1000)
<< ':';
}
if (g_log_tickcount)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698