From 0284a23d0ab5421107002894755c407dc767a007 Mon Sep 17 00:00:00 2001 From: gabime Date: Thu, 22 Aug 2019 19:57:59 +0300 Subject: [PATCH] Changed sink_it_ to accept const log_message& --- include/spdlog/async_logger-inl.h | 2 +- include/spdlog/async_logger.h | 3 +-- include/spdlog/details/thread_pool-inl.h | 2 +- include/spdlog/details/thread_pool.h | 4 ++-- include/spdlog/logger-inl.h | 2 +- include/spdlog/logger.h | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/spdlog/async_logger-inl.h b/include/spdlog/async_logger-inl.h index 45c6d8a9..e3866083 100644 --- a/include/spdlog/async_logger-inl.h +++ b/include/spdlog/async_logger-inl.h @@ -25,7 +25,7 @@ SPDLOG_INLINE spdlog::async_logger::async_logger( {} // send the log message to the thread pool -SPDLOG_INLINE void spdlog::async_logger::sink_it_(details::log_msg &msg) +SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg) { if (auto pool_ptr = thread_pool_.lock()) { diff --git a/include/spdlog/async_logger.h b/include/spdlog/async_logger.h index 9899837b..b3026f1d 100644 --- a/include/spdlog/async_logger.h +++ b/include/spdlog/async_logger.h @@ -52,9 +52,8 @@ public: std::shared_ptr clone(std::string new_name) override; protected: - void sink_it_(details::log_msg &msg) override; + void sink_it_(const details::log_msg &msg) override; void flush_() override; - void backend_log_(const details::log_msg &incoming_log_msg); void backend_flush_(); diff --git a/include/spdlog/details/thread_pool-inl.h b/include/spdlog/details/thread_pool-inl.h index 1f3837d5..38e3d135 100644 --- a/include/spdlog/details/thread_pool-inl.h +++ b/include/spdlog/details/thread_pool-inl.h @@ -51,7 +51,7 @@ SPDLOG_INLINE thread_pool::~thread_pool() SPDLOG_CATCH_ALL() {} } -void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy) +void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy) { async_msg async_m(std::move(worker_ptr), async_msg_type::log, msg); post_async_msg_(std::move(async_m), overflow_policy); diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index aa8bd42f..00c375d3 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -63,7 +63,7 @@ struct async_msg : log_msg_buffer #endif // construct from log_msg with given type - async_msg(async_logger_ptr &&worker, async_msg_type the_type, details::log_msg &m) + async_msg(async_logger_ptr &&worker, async_msg_type the_type, const details::log_msg &m) : log_msg_buffer{m} , msg_type{the_type} , worker_ptr{std::move(worker)} @@ -95,7 +95,7 @@ public: thread_pool(const thread_pool &) = delete; thread_pool &operator=(thread_pool &&) = delete; - void post_log(async_logger_ptr &&worker_ptr, details::log_msg &msg, async_overflow_policy overflow_policy); + void post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy); void post_flush(async_logger_ptr &&worker_ptr, async_overflow_policy overflow_policy); size_t overrun_counter(); diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 52d3fd5f..29a43dfa 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -161,7 +161,7 @@ SPDLOG_INLINE std::shared_ptr logger::clone(std::string logger_name) } // protected methods -SPDLOG_INLINE void logger::sink_it_(details::log_msg &msg) +SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg) { for (auto &sink : sinks_) { diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 2778fef4..bc497532 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -346,7 +346,7 @@ protected: spdlog::level_t flush_level_{level::off}; err_handler custom_err_handler_{nullptr}; - virtual void sink_it_(details::log_msg &msg); + virtual void sink_it_(const details::log_msg &msg); virtual void flush_(); bool should_flush_(const details::log_msg &msg);