This commit is contained in:
gabime
2019-08-29 01:05:23 +03:00
parent b693d0cd91
commit ed8d099607
6 changed files with 70 additions and 2 deletions

View File

@@ -83,3 +83,10 @@ SPDLOG_INLINE void spdlog::async_logger::backend_flush_()
SPDLOG_LOGGER_CATCH()
}
}
SPDLOG_INLINE std::shared_ptr<spdlog::logger> spdlog::async_logger::clone(std::string new_name)
{
auto cloned = std::make_shared<spdlog::async_logger>(*this);
cloned->name_ = std::move(new_name);
return cloned;
}

View File

@@ -49,6 +49,8 @@ public:
async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp,
async_overflow_policy overflow_policy = async_overflow_policy::block);
std::shared_ptr<logger> clone(std::string new_name) override;
protected:
void sink_it_(const details::log_msg &msg) override;
void flush_() override;

View File

@@ -122,7 +122,6 @@ struct formatter<spdlog::details::bytes_range<T>>
auto inserter = ctx.out();
#endif
for (auto &item : the_range)
{
auto ch = static_cast<unsigned char>(item);

View File

@@ -162,6 +162,14 @@ SPDLOG_INLINE void logger::set_error_handler(err_handler handler)
custom_err_handler_ = handler;
}
// create new logger with same sinks and configuration.
SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
{
auto cloned = std::make_shared<logger>(*this);
cloned->name_ = std::move(logger_name);
return cloned;
}
// protected methods
SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg)
{

View File

@@ -356,6 +356,9 @@ public:
// error handler
void set_error_handler(err_handler);
// create new logger with same sinks and configuration.
virtual std::shared_ptr<logger> clone(std::string logger_name);
protected:
std::string name_;
std::vector<sink_ptr> sinks_;