guangie88 / spdlog_setup

spdlog setup initialization via file configuration for convenience.
MIT License
78 stars 41 forks source link

[[thread_pool]] has bug #82

Open lys861205 opened 1 year ago

lys861205 commented 1 year ago

const auto thread_pools_map = setup_thread_pools(config); // set up loggers, setting the respective sinks and patterns setup_loggers(config, sinks_map, patterns_map, thread_pools_map);

thread_pools_map has contain std::shared_ptr, out of scope, thread_pool will be released, but logger still in use;logger has a thread_pool variable, the thread_pool variable is std::weak_ptr, that do not own raw ptr.

spdlog define SPDLOG_INLINE spdlog::async_logger::async_logger( std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp, async_overflow_policy overflow_policy) : async_logger(std::move(logger_name), {std::move(single_sink)}, std::move(tp), overflow_policy) {}

logger write log, will throw exception。

"async log: thread pool doesn't exist anymore"

e190 commented 1 year ago

try: static const auto thread_pools_map = setup_thread_pools(config);