File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 44#include < cmath>
55#include < cassert>
66#include < cstdio>
7+ #include < chrono>
8+ #include < ctime>
9+ #include < sstream>
710
811#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
912 #include < unistd.h>
@@ -131,9 +134,17 @@ void ProgressBar::ShowProgress() const {
131134 assert (progress_ratio <= 1.0 );
132135
133136 if (logging_mode_) {
134- *out << get_progress_summary (progress_ratio)
135- + " , " + std::to_string (progress_) + " /" + std::to_string (total_) + ' \n ' ;
136- out->flush ();
137+ // get current time
138+ auto now = std::chrono::system_clock::now ();
139+ std::time_t time = std::chrono::system_clock::to_time_t (now);
140+ auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
141+ now.time_since_epoch ()) % 1000 ;
142+ std::stringstream os;
143+ os << std::put_time (std::localtime (&time), " [%F %T." )
144+ << std::setfill (' 0' ) << std::setw (3 ) << ms.count () << " ]\t "
145+ << get_progress_summary (progress_ratio)
146+ << " , " + std::to_string (progress_) + " /" + std::to_string (total_) + ' \n ' ;
147+ *out << os.str () << std::flush;
137148 return ;
138149 }
139150
You can’t perform that action at this time.
0 commit comments