diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 227cec43..269932c2 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -207,14 +207,18 @@ SPDLOG_INLINE void logger::flush_() } } -SPDLOG_INLINE void logger::dump_backtrace_() +SPDLOG_INLINE void logger::dump_backtrace_(bool with_message) { using details::log_msg; if (tracer_.enabled() && !tracer_.empty()) { - sink_it_(log_msg{name(), level::info, "****************** Backtrace Start ******************"}); + if (with_message){ + sink_it_(log_msg{name(), level::info, "****************** Backtrace Start ******************"}); + } tracer_.foreach_pop([this](const log_msg &msg) { this->sink_it_(msg); }); - sink_it_(log_msg{name(), level::info, "****************** Backtrace End ********************"}); + if (with_message){ + sink_it_(log_msg{name(), level::info, "****************** Backtrace End ********************"}); + } } } diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index fbfe5fb8..0adbe47b 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -65,7 +65,7 @@ SPDLOG_API void enable_backtrace(size_t n_messages); SPDLOG_API void disable_backtrace(); // call dump backtrace on default logger -SPDLOG_API void dump_backtrace(); +SPDLOG_API void dump_backtrace(bool with_message=true); // Get global logging level SPDLOG_API level::level_enum get_level();