diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index 4b1395ca..eecf804a 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -125,9 +125,9 @@ private: // last exception thrown from the worker thread std::shared_ptr _last_workerthread_ex; - - // worker thread warmup callback - one can set thread priority, affinity, etc - const std::function _worker_warmup_cb; + + // worker thread warmup callback - one can set thread priority, affinity, etc + const std::function _worker_warmup_cb; // throw last worker thread exception or if worker thread is not active @@ -154,7 +154,7 @@ inline spdlog::details::async_log_helper::async_log_helper(formatter_ptr formatt _formatter(formatter), _sinks(sinks), _q(queue_size), - _worker_warmup_cb(worker_warmup_cb), + _worker_warmup_cb(worker_warmup_cb), _worker_thread(&async_log_helper::worker_loop, this) {} @@ -194,7 +194,7 @@ inline void spdlog::details::async_log_helper::worker_loop() { try { - if (_worker_warmup_cb) _worker_warmup_cb(); + if (_worker_warmup_cb) _worker_warmup_cb(); clock::time_point last_pop = clock::now(); while(process_next_msg(last_pop)); } diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h index ec341578..455f11c2 100644 --- a/include/spdlog/details/async_logger_impl.h +++ b/include/spdlog/details/async_logger_impl.h @@ -44,7 +44,10 @@ inline spdlog::async_logger::async_logger(const std::string& logger_name, sinks_ async_logger(logger_name, sinks.begin(), sinks.end(), queue_size, worker_warmup_cb) {} inline spdlog::async_logger::async_logger(const std::string& logger_name, sink_ptr single_sink, size_t queue_size, const std::function& worker_warmup_cb) : - async_logger(logger_name, { single_sink }, queue_size, worker_warmup_cb) {} + async_logger(logger_name, +{ + single_sink +}, queue_size, worker_warmup_cb) {} inline void spdlog::async_logger::_set_formatter(spdlog::formatter_ptr msg_formatter) diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index a3911e97..9c25845f 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -125,7 +125,7 @@ public: std::lock_guard lock(_mutex); _async_mode = true; _async_q_size = q_size; - _worker_warmup_cb = worker_warmup_cb; + _worker_warmup_cb = worker_warmup_cb; } void set_sync_mode() @@ -151,7 +151,7 @@ private: level::level_enum _level = level::info; bool _async_mode = false; size_t _async_q_size = 0; - std::function _worker_warmup_cb = nullptr; + std::function _worker_warmup_cb = nullptr; }; } } diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 89153895..92894b85 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -63,7 +63,7 @@ void set_level(level::level_enum log_level); // Turn on async mode and set the queue size for each async_logger -void set_async_mode(size_t queue_size, const std::function& worker_warmup_cb); +void set_async_mode(size_t queue_size, const std::function& worker_warmup_cb = nullptr); // Turn off async mode void set_sync_mode();