|
|
@ -311,15 +311,7 @@ class R_formatter SPDLOG_FINAL:public flag_formatter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
|
|
void format(details::log_msg& msg, const std::tm& tm_time) override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
msg.formatted << (tm_time.tm_year + 1900);
|
|
|
|
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, ':');
|
|
|
|
msg.formatted << '-';
|
|
|
|
|
|
|
|
msg.formatted << tm_time.tm_mon;
|
|
|
|
|
|
|
|
msg.formatted << '-';
|
|
|
|
|
|
|
|
msg.formatted << tm_time.tm_mday;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
msg.formatted << ' ';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pad_n_join(msg.formatted, tm_time.tm_hour, tm_time.tm_min, ':');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -502,13 +494,13 @@ class full_formatter SPDLOG_FINAL:public flag_formatter
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// pattern_formatter inline impl
|
|
|
|
// pattern_formatter inline impl
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
inline spdlog::pattern_formatter::pattern_formatter(const std::string& pattern, pattern_time ptime)
|
|
|
|
inline spdlog::pattern_formatter::pattern_formatter(const std::string& pattern, pattern_time_type pattern_time)
|
|
|
|
: _time(ptime)
|
|
|
|
: _pattern_time(pattern_time)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
compile_pattern(pattern, _time);
|
|
|
|
compile_pattern(pattern);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void spdlog::pattern_formatter::compile_pattern(const std::string& pattern, pattern_time ptime)
|
|
|
|
inline void spdlog::pattern_formatter::compile_pattern(const std::string& pattern)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto end = pattern.end();
|
|
|
|
auto end = pattern.end();
|
|
|
|
std::unique_ptr<details::aggregate_formatter> user_chars;
|
|
|
|
std::unique_ptr<details::aggregate_formatter> user_chars;
|
|
|
@ -673,26 +665,18 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline std::tm spdlog::pattern_formatter::get_time(details::log_msg& msg) {
|
|
|
|
|
|
|
|
if (_pattern_time == pattern_time_type::local)
|
|
|
|
|
|
|
|
return details::os::localtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return details::os::gmtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void spdlog::pattern_formatter::format(details::log_msg& msg)
|
|
|
|
inline void spdlog::pattern_formatter::format(details::log_msg& msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SPDLOG_NO_DATETIME
|
|
|
|
#ifndef SPDLOG_NO_DATETIME
|
|
|
|
auto tm_time = [this, &msg]()
|
|
|
|
auto tm_time = get_time(msg);
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (_time)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// it is always faster to put the most-common/default case first
|
|
|
|
|
|
|
|
case (pattern_time::local):
|
|
|
|
|
|
|
|
return details::os::localtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case (pattern_time::utc):
|
|
|
|
|
|
|
|
return details::os::gmtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return details::os::localtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
std::tm tm_time;
|
|
|
|
std::tm tm_time;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|