mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
support set_formatter in spdlog.h
This commit is contained in:
@@ -37,19 +37,18 @@ inline spdlog::logger::logger(std::string logger_name, spdlog::sink_ptr single_s
|
||||
|
||||
inline spdlog::logger::~logger() = default;
|
||||
|
||||
template<typename FormatterT, typename... Args>
|
||||
inline void spdlog::logger::set_formatter(const Args &... args)
|
||||
|
||||
inline void spdlog::logger::set_formatter(std::unique_ptr<spdlog::formatter> f)
|
||||
{
|
||||
for (auto &sink : sinks_)
|
||||
{
|
||||
std::unique_ptr<FormatterT> formatter(new FormatterT(args...));
|
||||
sink->set_formatter(std::move(formatter));
|
||||
}
|
||||
for (auto &sink : sinks_)
|
||||
{
|
||||
sink->set_formatter(f->clone());
|
||||
}
|
||||
}
|
||||
|
||||
inline void spdlog::logger::set_pattern(std::string pattern, pattern_time_type time_type)
|
||||
{
|
||||
set_formatter<spdlog::pattern_formatter>(std::move(pattern), time_type);
|
||||
set_formatter(std::unique_ptr<spdlog::formatter>(new pattern_formatter(std::move(pattern), time_type)));
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
|
||||
Reference in New Issue
Block a user