defer localtime to formatter to improve async performace

This commit is contained in:
gabime
2014-12-04 11:48:53 +02:00
parent c215ee6104
commit 754cac85ac
6 changed files with 88 additions and 92 deletions

View File

@@ -37,8 +37,7 @@ struct log_msg
log_msg(level::level_enum l):
logger_name(),
level(l),
time(),
tm_time(),
time(),
raw(),
formatted() {}
@@ -46,9 +45,7 @@ struct log_msg
log_msg(const log_msg& other) :
logger_name(other.logger_name),
level(other.level),
time(other.time),
tm_time(other.tm_time)
time(other.time)
{
if (other.raw.size())
raw << fmt::BasicStringRef<char>(other.raw.data(), other.raw.size());
@@ -60,8 +57,7 @@ struct log_msg
log_msg(log_msg&& other) :
logger_name(std::move(other.logger_name)),
level(other.level),
time(std::move(other.time)),
tm_time(other.tm_time),
time(std::move(other.time)),
raw(std::move(other.raw)),
formatted(std::move(other.formatted))
{
@@ -75,8 +71,7 @@ struct log_msg
logger_name = std::move(other.logger_name);
level = other.level;
time = std::move(other.time);
tm_time = other.tm_time;
time = std::move(other.time);
raw = std::move(other.raw);
formatted = std::move(other.formatted);
other.clear();
@@ -95,7 +90,7 @@ struct log_msg
std::string logger_name;
level::level_enum level;
log_clock::time_point time;
std::tm tm_time;
//std::tm tm_time;
fmt::MemoryWriter raw;
fmt::MemoryWriter formatted;
};