mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 09:40:05 +08:00
astyle
This commit is contained in:
@@ -28,13 +28,12 @@ public:
|
||||
class default_formatter: public formatter {
|
||||
public:
|
||||
// Format: [2013-12-29 01:04:42.900] [logger_name:Info] Message body
|
||||
void format_header(const std::string& logger_name, level::level_enum level, const time_point& tp, std::ostream& dest) override
|
||||
{
|
||||
void format_header(const std::string& logger_name, level::level_enum level, const time_point& tp, std::ostream& dest) override {
|
||||
_format_time(tp, dest);
|
||||
dest << " [" << logger_name << ":" << c11log::level::to_str(level) << "] ";
|
||||
}
|
||||
private:
|
||||
void _format_time(const time_point& tp, std::ostream &dest);
|
||||
void _format_time(const time_point& tp, std::ostream &dest);
|
||||
|
||||
};
|
||||
} //namespace formatter
|
||||
@@ -46,20 +45,19 @@ inline void c11log::formatters::default_formatter::_format_time(const time_point
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
static thread_local c11log::formatters::time_point last_tp;
|
||||
static thread_local char timestamp_cache[64];
|
||||
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;
|
||||
|
||||
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;
|
||||
dest << timestamp_cache;
|
||||
}
|
||||
|
Reference in New Issue
Block a user