From cd2a484e96d8c2f4d0269bcacb4503eb4b724203 Mon Sep 17 00:00:00 2001 From: gabime Date: Thu, 15 Jan 2015 10:27:36 +0200 Subject: [PATCH] reordered members definition in async_log_helper to prevent gcc warning --- example/example.cpp | 3 ++- include/spdlog/details/async_log_helper.h | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/example/example.cpp b/example/example.cpp index c2cfecb3..89bd3388 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -38,7 +38,8 @@ int main(int, char* []) // Create console, multithreaded logger auto console = spd::stdout_logger_mt("console"); - console->info("Welcome to spdlog!") ; + const std::string s("Hello {}", 1); + console->info(s) ; console->info("An info message example {}..", 1); console->info() << "Streams are supported too " << 1; diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index 07ff5c6b..090d5d0a 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -109,7 +109,12 @@ public: using clock = std::chrono::steady_clock; - async_log_helper(formatter_ptr formatter, const std::vector& sinks, size_t queue_size, const async_queue_overflow_policy overflow_policy = async_queue_overflow_policy::block_retry, const std::function& worker_warmup_cb = nullptr); + async_log_helper(formatter_ptr formatter, + const std::vector& sinks, + size_t queue_size, + const async_queue_overflow_policy overflow_policy = async_queue_overflow_policy::block_retry, + const std::function& worker_warmup_cb = nullptr); + void log(const details::log_msg& msg); //Stop logging and join the back thread @@ -120,9 +125,10 @@ public: private: formatter_ptr _formatter; std::vector> _sinks; + + // queue of messages to log q_type _q; - std::thread _worker_thread; - + // last exception thrown from the worker thread std::shared_ptr _last_workerthread_ex; @@ -131,8 +137,10 @@ private: // worker thread warmup callback - one can set thread priority, affinity, etc const std::function _worker_warmup_cb; - - + + // worker thread + std::thread _worker_thread; + // throw last worker thread exception or if worker thread is not active void throw_if_bad_worker();