From 4f2ce074be5f86d45f33b1611713028f095cd424 Mon Sep 17 00:00:00 2001 From: rwen2012 Date: Tue, 30 Oct 2018 17:12:11 +0800 Subject: [PATCH] change the logger's sink_it_ parameter from lvalue reference to rvalue reference --- include/spdlog/async_logger.h | 2 +- include/spdlog/details/async_logger_impl.h | 2 +- include/spdlog/details/logger_impl.h | 10 +++++----- include/spdlog/logger.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/spdlog/async_logger.h b/include/spdlog/async_logger.h index a7ecb787..c909e2c1 100644 --- a/include/spdlog/async_logger.h +++ b/include/spdlog/async_logger.h @@ -58,7 +58,7 @@ public: std::shared_ptr clone(std::string new_name) override; protected: - void sink_it_(details::log_msg &msg) override; + void sink_it_(details::log_msg &&msg) override; void flush_() override; void backend_log_(const details::log_msg &incoming_log_msg); diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h index 2841ab2b..b23490f3 100644 --- a/include/spdlog/details/async_logger_impl.h +++ b/include/spdlog/details/async_logger_impl.h @@ -36,7 +36,7 @@ inline spdlog::async_logger::async_logger( } // send the log message to the thread pool -inline void spdlog::async_logger::sink_it_(details::log_msg &msg) +inline void spdlog::async_logger::sink_it_(details::log_msg &&msg) { #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) incr_msg_counter_(msg); diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index 850f8639..7a91d64f 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -67,7 +67,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const char *fmt, const Ar fmt::memory_buffer buf; fmt::format_to(buf, fmt, args...); details::log_msg log_msg(&name_, lvl, to_string_view(buf)); - sink_it_(log_msg); + sink_it_(std::move(log_msg)); } SPDLOG_CATCH_AND_HANDLE } @@ -82,7 +82,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const char *msg) try { details::log_msg log_msg(&name_, lvl, spdlog::string_view_t(msg)); - sink_it_(log_msg); + sink_it_(std::move(log_msg)); } SPDLOG_CATCH_AND_HANDLE } @@ -97,7 +97,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const T &msg) try { details::log_msg log_msg(&name_, lvl, msg); - sink_it_(log_msg); + sink_it_(std::move(log_msg)); } SPDLOG_CATCH_AND_HANDLE } @@ -115,7 +115,7 @@ inline void spdlog::logger::log(level::level_enum lvl, const T &msg) fmt::memory_buffer buf; fmt::format_to(buf, "{}", msg); details::log_msg log_msg(&name_, lvl, to_string_view(buf)); - sink_it_(log_msg); + sink_it_(std::move(log_msg)); } SPDLOG_CATCH_AND_HANDLE } @@ -337,7 +337,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons // protected virtual called at end of each user log call (if enabled) by the // line_logger // -inline void spdlog::logger::sink_it_(details::log_msg &msg) +inline void spdlog::logger::sink_it_(details::log_msg &&msg) { #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) incr_msg_counter_(msg); diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 4e08076b..e434ba5d 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -146,7 +146,7 @@ public: virtual std::shared_ptr clone(std::string logger_name); protected: - virtual void sink_it_(details::log_msg &msg); + virtual void sink_it_(details::log_msg &&msg); virtual void flush_(); bool should_flush_(const details::log_msg &msg);