Fixed logger's copy ctor

This commit is contained in:
gabime 2019-08-27 01:56:48 +03:00
parent 72b0f9e8f7
commit 11e9752536
2 changed files with 14 additions and 3 deletions

View File

@ -17,13 +17,19 @@ namespace details {
class backtracer
{
std::mutex mutex_;
size_t n_messages_;
circular_q<log_msg_buffer> messages_;
public:
explicit backtracer(size_t n_message)
: messages_{n_message}
explicit backtracer(size_t n_messages)
: n_messages_{n_messages}, messages_{n_messages}
{}
size_t n_messages()
{
return n_messages_;
}
void add(const log_msg &msg)
{
std::lock_guard<std::mutex> lock{mutex_};

View File

@ -23,7 +23,12 @@ SPDLOG_INLINE logger::logger(const logger &other)
, flush_level_(other.flush_level_.load(std::memory_order_relaxed))
, custom_err_handler_(other.custom_err_handler_)
, tracer_(other.tracer_)
{}
{
if(other.tracer_)
{
enable_backtrace(other.tracer_->n_messages());
}
}
SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT : name_(std::move(other.name_)),
sinks_(std::move(other.sinks_)),