Commit e83cc703 authored by gabime's avatar gabime

readded set_pattern impl

parent 0bcfc881
......@@ -290,6 +290,7 @@ public:
// set formatting for the sinks in this logger.
// each sink will get a separate instance of the formatter object.
void set_formatter(std::unique_ptr<formatter> f);
void set_pattern(std::string pattern);
// backtrace support.
// efficiently store all debug/trace messages in a circular buffer until needed for debugging.
......
......@@ -12,6 +12,7 @@
#include <spdlog/details/os.h>
#include <spdlog/fmt/fmt.h>
#include <spdlog/formatter.h>
#include <spdlog/logger.h>
#include <algorithm>
#include <array>
......@@ -1287,4 +1288,14 @@ SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &patter
formatters_.push_back(std::move(user_chars));
}
}
SPDLOG_INLINE void set_pattern(std::string pattern)
{
set_formatter(details::make_unique<pattern_formatter>(std::move(pattern)));
}
SPDLOG_INLINE void logger::set_pattern(std::string pattern)
{
this->set_formatter(details::make_unique<pattern_formatter>(std::move(pattern)));
}
} // namespace spdlog
......@@ -55,6 +55,9 @@ SPDLOG_API std::shared_ptr<logger> get(const std::string &name);
// example: spdlog::set_formatter(std::make_unique<spdlog::pattern_formatter>("%Y-%m-%d %H:%M:%S.%e %l : %v"));
SPDLOG_API void set_formatter(std::unique_ptr<spdlog::formatter> formatter);
// Set global log pattern.
SPDLOG_API void set_pattern(std::string pattern);
// enable global backtrace support
SPDLOG_API void enable_backtrace(size_t n_messages);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment