Commit 11e97525 authored by gabime's avatar gabime

Fixed logger's copy ctor

parent 72b0f9e8
...@@ -17,13 +17,19 @@ namespace details { ...@@ -17,13 +17,19 @@ namespace details {
class backtracer class backtracer
{ {
std::mutex mutex_; std::mutex mutex_;
size_t n_messages_;
circular_q<log_msg_buffer> messages_; circular_q<log_msg_buffer> messages_;
public: public:
explicit backtracer(size_t n_message) explicit backtracer(size_t n_messages)
: messages_{n_message} : n_messages_{n_messages}, messages_{n_messages}
{} {}
size_t n_messages()
{
return n_messages_;
}
void add(const log_msg &msg) void add(const log_msg &msg)
{ {
std::lock_guard<std::mutex> lock{mutex_}; std::lock_guard<std::mutex> lock{mutex_};
......
...@@ -23,7 +23,12 @@ SPDLOG_INLINE logger::logger(const logger &other) ...@@ -23,7 +23,12 @@ SPDLOG_INLINE logger::logger(const logger &other)
, flush_level_(other.flush_level_.load(std::memory_order_relaxed)) , flush_level_(other.flush_level_.load(std::memory_order_relaxed))
, custom_err_handler_(other.custom_err_handler_) , custom_err_handler_(other.custom_err_handler_)
, tracer_(other.tracer_) , 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_)), SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT : name_(std::move(other.name_)),
sinks_(std::move(other.sinks_)), sinks_(std::move(other.sinks_)),
......
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