Added default pattern support for pattern_formatter to avoid parsing pattern when using default pattern

This commit is contained in:
gabime 2018-11-11 01:18:57 +02:00
parent 7d7ccac416
commit dc166cad92
3 changed files with 14 additions and 2 deletions

View File

@ -869,6 +869,18 @@ public:
compile_pattern_(pattern_); compile_pattern_(pattern_);
} }
// use by default full formatter for if pattern is not given
explicit pattern_formatter(
pattern_time_type time_type = pattern_time_type::local, std::string eol = spdlog::details::os::default_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()));
}
pattern_formatter(const pattern_formatter &other) = delete; pattern_formatter(const pattern_formatter &other) = delete;
pattern_formatter &operator=(const pattern_formatter &other) = delete; pattern_formatter &operator=(const pattern_formatter &other) = delete;

View File

@ -231,7 +231,7 @@ public:
private: private:
registry() registry()
: formatter_(new pattern_formatter("%+")) : formatter_(new pattern_formatter())
{ {
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER #ifndef SPDLOG_DISABLE_DEFAULT_LOGGER

View File

@ -16,7 +16,7 @@ class sink
public: public:
sink() sink()
: level_(level::trace) : level_(level::trace)
, formatter_(new pattern_formatter("%+")) , formatter_(new pattern_formatter())
{ {
} }