mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
fixes and imprvts
This commit is contained in:
@@ -4,16 +4,20 @@
|
||||
|
||||
void c11log::formatters::format_time(const c11log::formatters::timepoint& tp, std::ostream &dest)
|
||||
{
|
||||
|
||||
std::tm tm = details::os::localtime(std::chrono::system_clock::to_time_t(tp));
|
||||
//get ms
|
||||
auto duration = tp.time_since_epoch();
|
||||
int millis = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000);
|
||||
//std::put_time(&tm, "[ %Y-%m-%d %H:%M:%S ]") - seems too slow
|
||||
//auto duration = tp.time_since_epoch();
|
||||
//int millis = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000);
|
||||
|
||||
|
||||
char buf[64];
|
||||
auto size = sprintf(buf, "[%d-%02d-%02d %02d:%02d:%02d.%03d]",
|
||||
auto size = sprintf(buf, "[%d-%02d-%02d %02d:%02d:%02d]",
|
||||
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec, millis);
|
||||
dest.write(buf, size);
|
||||
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
|
||||
dest.write(buf, size);
|
||||
|
||||
}
|
||||
|
||||
void c11log::formatters::format_time(std::ostream& dest)
|
||||
|
Reference in New Issue
Block a user