mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
Fixed #1197
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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_;
|
||||
|
Reference in New Issue
Block a user