From eab2f57bb3ea252729d52db329a31e54ccf02a2f Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Thu, 3 Aug 2023 11:03:11 +0200 Subject: [PATCH] Shows microsecs instead of millisecs --- src/log4cpp.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/log4cpp.cpp b/src/log4cpp.cpp index 9581282..403fe86 100644 --- a/src/log4cpp.cpp +++ b/src/log4cpp.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -35,13 +34,12 @@ void print_timestamp() // retrieve accurate time for milliseconds display struct timeval secs; (void)::gettimeofday(&secs, nullptr); - int ms = static_cast(std::roundf(secs.tv_usec / 1000.0)) % 1000; // create a date/time stamp char dtstamp[20]; std::strftime(dtstamp, 20, "%F %T", std::localtime(&secs.tv_sec)); - std::cerr << dtstamp << "." << std::setw(3) << ms << " "; + std::cerr << dtstamp << "." << std::setw(6) << secs.tv_usec << " "; #if __APPLE__ std::cerr << getprogname() << "[" << getpid() << "] "; #elif __linux__