diff --git a/util/stderr_logger.h b/util/stderr_logger.h index abf8f57010..97bd625618 100644 --- a/util/stderr_logger.h +++ b/util/stderr_logger.h @@ -8,6 +8,7 @@ #include #include +#include "port/sys_time.h" #include "rocksdb/env.h" namespace ROCKSDB_NAMESPACE { @@ -23,6 +24,18 @@ class StderrLogger : public Logger { using Logger::Logv; virtual void Logv(const char* format, va_list ap) override { + const uint64_t thread_id = Env::Default()->GetThreadID(); + + port::TimeVal now_tv; + port::GetTimeOfDay(&now_tv, nullptr); + const time_t seconds = now_tv.tv_sec; + struct tm t; + port::LocalTimeR(&seconds, &t); + fprintf(stderr, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ", + t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, + t.tm_sec, static_cast(now_tv.tv_usec), + static_cast(thread_id)); + vfprintf(stderr, format, ap); fprintf(stderr, "\n"); }