|
|
|
@ -959,37 +959,34 @@ private:
|
|
|
|
|
|
|
|
|
|
} // namespace details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE pattern_formatter::pattern_formatter(
|
|
|
|
|
std::string pattern, pattern_time_type time_type, std::string eol)
|
|
|
|
|
SPDLOG_INLINE pattern_formatter::pattern_formatter(std::string pattern, pattern_time_type time_type, std::string eol)
|
|
|
|
|
: pattern_(std::move(pattern))
|
|
|
|
|
, eol_(std::move(eol))
|
|
|
|
|
, pattern_time_type_(time_type)
|
|
|
|
|
, last_log_secs_(0)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
|
|
|
|
compile_pattern_(pattern_);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// use by default full formatter for if pattern is not given
|
|
|
|
|
SPDLOG_INLINE pattern_formatter::pattern_formatter(pattern_time_type time_type, std::string eol)
|
|
|
|
|
// use by default full formatter for if pattern is not given
|
|
|
|
|
SPDLOG_INLINE pattern_formatter::pattern_formatter(pattern_time_type time_type, std::string eol)
|
|
|
|
|
: pattern_("%+")
|
|
|
|
|
, eol_(std::move(eol))
|
|
|
|
|
, pattern_time_type_(time_type)
|
|
|
|
|
, last_log_secs_(0)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
std::memset(&cached_tm_, 0, sizeof(cached_tm_));
|
|
|
|
|
formatters_.push_back(details::make_unique<details::full_formatter>(details::padding_info{}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE std::unique_ptr<formatter> pattern_formatter::clone() const
|
|
|
|
|
{
|
|
|
|
|
SPDLOG_INLINE std::unique_ptr<formatter> pattern_formatter::clone() const
|
|
|
|
|
{
|
|
|
|
|
return details::make_unique<pattern_formatter>(pattern_, pattern_time_type_, eol_);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, fmt::memory_buffer &dest)
|
|
|
|
|
{
|
|
|
|
|
SPDLOG_INLINE void pattern_formatter::format(const details::log_msg &msg, fmt::memory_buffer &dest)
|
|
|
|
|
{
|
|
|
|
|
#ifndef SPDLOG_NO_DATETIME
|
|
|
|
|
auto secs = std::chrono::duration_cast<std::chrono::seconds>(msg.time.time_since_epoch());
|
|
|
|
|
if (secs != last_log_secs_)
|
|
|
|
@ -1004,19 +1001,19 @@ private:
|
|
|
|
|
}
|
|
|
|
|
// write eol
|
|
|
|
|
details::fmt_helper::append_string_view(eol_, dest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE std::tm pattern_formatter::get_time_(const details::log_msg &msg)
|
|
|
|
|
{
|
|
|
|
|
SPDLOG_INLINE std::tm pattern_formatter::get_time_(const details::log_msg &msg)
|
|
|
|
|
{
|
|
|
|
|
if (pattern_time_type_ == pattern_time_type::local)
|
|
|
|
|
{
|
|
|
|
|
return details::os::localtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
}
|
|
|
|
|
return details::os::gmtime(log_clock::to_time_t(msg.time));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_info padding)
|
|
|
|
|
{
|
|
|
|
|
SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_info padding)
|
|
|
|
|
{
|
|
|
|
|
switch (flag)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -1178,13 +1175,13 @@ private:
|
|
|
|
|
formatters_.push_back((std::move(unknown_flag)));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extract given pad spec (e.g. %8X)
|
|
|
|
|
// Advance the given it pass the end of the padding spec found (if any)
|
|
|
|
|
// Return padding.
|
|
|
|
|
SPDLOG_INLINE details::padding_info pattern_formatter::handle_padspec_(std::string::const_iterator &it, std::string::const_iterator end)
|
|
|
|
|
{
|
|
|
|
|
// Extract given pad spec (e.g. %8X)
|
|
|
|
|
// Advance the given it pass the end of the padding spec found (if any)
|
|
|
|
|
// Return padding.
|
|
|
|
|
SPDLOG_INLINE details::padding_info pattern_formatter::handle_padspec_(std::string::const_iterator &it, std::string::const_iterator end)
|
|
|
|
|
{
|
|
|
|
|
using details::padding_info;
|
|
|
|
|
using details::scoped_pad;
|
|
|
|
|
const size_t max_width = 128;
|
|
|
|
@ -1221,10 +1218,10 @@ private:
|
|
|
|
|
width = width * 10 + digit;
|
|
|
|
|
}
|
|
|
|
|
return details::padding_info{std::min<size_t>(width, max_width), side};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &pattern)
|
|
|
|
|
{
|
|
|
|
|
SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &pattern)
|
|
|
|
|
{
|
|
|
|
|
auto end = pattern.end();
|
|
|
|
|
std::unique_ptr<details::aggregate_formatter> user_chars;
|
|
|
|
|
formatters_.clear();
|
|
|
|
@ -1261,6 +1258,5 @@ private:
|
|
|
|
|
{
|
|
|
|
|
formatters_.push_back(std::move(user_chars));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // namespace spdlog
|
|
|
|
|
|
|
|
|
|