mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-12 17:00:25 +08:00
Protect from double call to enable_backtrace()
This commit is contained in:
parent
e085ba7fcc
commit
8d8aacf5e9
@ -120,14 +120,21 @@ SPDLOG_INLINE void logger::set_pattern(std::string pattern, pattern_time_type ti
|
||||
set_formatter(std::move(new_formatter));
|
||||
}
|
||||
|
||||
|
||||
// create new backtrace sink and hand it all sinks
|
||||
SPDLOG_INLINE void logger::enable_backtrace(level::level_enum trigger_level, size_t n_messages)
|
||||
{
|
||||
auto backtrace_sink = std::make_shared<spdlog::sinks::backtrace_sink_mt>(trigger_level, n_messages);
|
||||
backtrace_sink->set_sinks(std::move(sinks()));
|
||||
sinks().push_back(std::move(backtrace_sink));
|
||||
this->set_level(spdlog::level::trace);
|
||||
if(!backtrace_enabled_)
|
||||
{
|
||||
backtrace_enabled_ = true;
|
||||
auto backtrace_sink = std::make_shared<spdlog::sinks::backtrace_sink_mt>(trigger_level, n_messages);
|
||||
backtrace_sink->set_sinks(std::move(sinks()));
|
||||
sinks().push_back(std::move(backtrace_sink));
|
||||
this->set_level(spdlog::level::trace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// flush functions
|
||||
SPDLOG_INLINE void logger::flush()
|
||||
{
|
||||
|
@ -347,6 +347,7 @@ protected:
|
||||
spdlog::level_t level_{level::info};
|
||||
spdlog::level_t flush_level_{level::off};
|
||||
err_handler custom_err_handler_{nullptr};
|
||||
bool backtrace_enabled_ {false};
|
||||
|
||||
virtual void sink_it_(const details::log_msg &msg);
|
||||
virtual void flush_();
|
||||
|
Loading…
Reference in New Issue
Block a user