header only\!

This commit is contained in:
gabime
2014-02-20 21:39:58 +02:00
parent 8176f82de2
commit 3feba27f8b
12 changed files with 90 additions and 152 deletions

View File

@@ -39,3 +39,27 @@ private:
};
} //namespace formatter
} //namespace c11log
inline void c11log::formatters::default_formatter::_format_time(const time_point& tp, std::ostream &dest)
{
using namespace std::chrono;
static thread_local c11log::formatters::time_point last_tp;
static thread_local char timestamp_cache[64];
if(duration_cast<milliseconds>(tp-last_tp).count() > 950)
{
auto tm = details::os::localtime(clock::to_time_t(tp));
sprintf(timestamp_cache, "[%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);
last_tp = tp;
}
dest << timestamp_cache;
}