diff --git a/bench/latency.cpp b/bench/latency.cpp index 2a7787d6..d62ca5d4 100644 --- a/bench/latency.cpp +++ b/bench/latency.cpp @@ -38,6 +38,7 @@ void prepare_logdir() void bench_c_string(benchmark::State &state, std::shared_ptr logger) { + logger->enable_backtrace(64); const char *msg = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pharetra metus cursus " "lacus placerat congue. Nulla egestas, mauris a tincidunt tempus, enim lectus volutpat mi, eu consequat sem " "libero nec massa. In dapibus ipsum a diam rhoncus gravida. Etiam non dapibus eros. Donec fringilla dui sed " @@ -52,6 +53,7 @@ void bench_c_string(benchmark::State &state, std::shared_ptr log void bench_logger(benchmark::State &state, std::shared_ptr logger) { + logger->enable_backtrace(64); int i = 0; for (auto _ : state) { @@ -61,6 +63,7 @@ void bench_logger(benchmark::State &state, std::shared_ptr logge void bench_disabled_macro(benchmark::State &state, std::shared_ptr logger) { + logger->enable_backtrace(64); int i = 0; benchmark::DoNotOptimize(i); // prevent unused warnings benchmark::DoNotOptimize(logger); // prevent unused warnings diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index c75934d1..eceefa0a 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -138,7 +138,7 @@ SPDLOG_INLINE void logger::enable_backtrace(size_t n_messages) { if (!backtrace_sink_) { - backtrace_sink_ = std::make_shared((std::move(sinks_), level(), n_messages)); + backtrace_sink_ = std::make_shared(std::move(sinks_), level(), n_messages); sinks().push_back(backtrace_sink_); level_.store(level::trace); // pass all messages to the backtrace sink. }