Added "clone()" support to loggers

This commit is contained in:
gabime
2018-08-25 17:55:31 +03:00
parent 91d8869f36
commit 5d7845c138
8 changed files with 21 additions and 17 deletions

View File

@@ -99,13 +99,9 @@ inline void spdlog::async_logger::backend_flush_()
SPDLOG_CATCH_AND_HANDLE
}
inline std::shared_ptr<spdlog::logger> spdlog::async_logger::clone(std::string new_name)
{
auto cloned = std::make_shared<spdlog::async_logger>(std::move(new_name),
sinks_.begin(), sinks_.end(),
thread_pool_,
overflow_policy_);
auto cloned = std::make_shared<spdlog::async_logger>(std::move(new_name), sinks_.begin(), sinks_.end(), thread_pool_, overflow_policy_);
cloned->set_level(this->level());
cloned->flush_on(this->flush_level());

View File

@@ -22,8 +22,8 @@ inline void append_str(const std::string &str, fmt::basic_memory_buffer<char, Bu
template<size_t Buffer_Size>
inline void append_c_str(const char *c_str, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
{
auto len = std::char_traits<char>::length(c_str);
dest.append(c_str, c_str + len);
auto len = std::char_traits<char>::length(c_str);
dest.append(c_str, c_str + len);
}
template<size_t Buffer_Size1, size_t Buffer_Size2>

View File

@@ -10,7 +10,6 @@
#include <memory>
#include <string>
// create logger with given name, sinks and the default pattern formatter
// all other ctors will call this one
template<typename It>
@@ -79,8 +78,8 @@ inline void spdlog::logger::log(level::level_enum lvl, const char *msg)
}
try
{
details::log_msg log_msg(&name_, lvl);
details::fmt_helper::append_c_str(msg, log_msg.raw);
details::log_msg log_msg(&name_, lvl);
details::fmt_helper::append_c_str(msg, log_msg.raw);
sink_it_(log_msg);
}
SPDLOG_CATCH_AND_HANDLE
@@ -276,7 +275,6 @@ inline spdlog::level::level_enum spdlog::logger::flush_level() const
return static_cast<spdlog::level::level_enum>(flush_level_.load(std::memory_order_relaxed));
}
inline bool spdlog::logger::should_flush_(const details::log_msg &msg)
{
auto flush_level = flush_level_.load(std::memory_order_relaxed);

View File

@@ -115,7 +115,6 @@ public:
level::level_enum level() const;
const std::string &name() const;
// set formatting for the sinks in this logger.
// each sink will get a seperate instance of the formatter object.
void set_formatter(std::unique_ptr<formatter> formatter);