|
|
|
@ -5,6 +5,7 @@
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
|
|
#include "common_types.h"
|
|
|
|
|
#include "details/os.h"
|
|
|
|
@ -43,20 +44,21 @@ private:
|
|
|
|
|
|
|
|
|
|
inline void c11log::formatters::default_formatter::_format_time(const log_clock::time_point& tp, std::ostream &dest)
|
|
|
|
|
{
|
|
|
|
|
static thread_local std::tm last_tm = {0,0,0,0,0,0,0,0,0,0,0};
|
|
|
|
|
static thread_local char last_time_str[64];
|
|
|
|
|
|
|
|
|
|
__declspec(thread) static std::tm last_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
|
__declspec(thread) static char last_time_str[64];
|
|
|
|
|
auto tm_now = details::os::localtime(log_clock::to_time_t(tp));
|
|
|
|
|
|
|
|
|
|
if(last_tm != tm_now)
|
|
|
|
|
{
|
|
|
|
|
sprintf(last_time_str, "[%d-%02d-%02d %02d:%02d:%02d]",
|
|
|
|
|
sprintf(last_time_str, "[%d-%02d-%02d %02d:%02d:%02d]",
|
|
|
|
|
tm_now.tm_year + 1900,
|
|
|
|
|
tm_now.tm_mon + 1,
|
|
|
|
|
tm_now.tm_mday,
|
|
|
|
|
tm_now.tm_hour,
|
|
|
|
|
tm_now.tm_min,
|
|
|
|
|
tm_now.tm_sec);
|
|
|
|
|
last_tm = tm_now;
|
|
|
|
|
}
|
|
|
|
|
dest << last_time_str;
|
|
|
|
|
last_tm = tm_now;
|
|
|
|
|
}
|
|
|
|
|
dest << last_time_str;
|
|
|
|
|
}
|
|
|
|
|