replaced spdlog::shutdown() with spdlog::release_thread_pool()

pull/2143/head
gabime 4 years ago
parent 7fb36c25d8
commit 11a98a8cb4

@ -140,7 +140,7 @@ int main(int argc, char *argv[])
std::make_shared<async_logger>("async_logger", std::move(file_sink), std::move(tp), async_overflow_policy::overrun_oldest);
bench_mt(howmany, std::move(logger), threads);
}
spdlog::shutdown();
spdlog::release_thread_pool();
}
catch (std::exception &ex)
{

@ -71,10 +71,6 @@ int main(int, char *[])
stopwatch_example();
udp_example();
custom_flags_example();
// Release all spdlog resources, and drop all loggers in the registry.
// This is optional (only mandatory if using windows + async log).
spdlog::shutdown();
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging).
@ -141,6 +137,7 @@ void async_example()
{
async_file->info("Async message #{}", i);
}
spdlog::release_thread_pool();
}
// Log binary data as hex.

@ -86,4 +86,11 @@ inline std::shared_ptr<spdlog::details::thread_pool> thread_pool()
{
return details::s_thread_pool;
}
// shutdown the thread pool. needed to called in windows before main() exits.
inline void release_thread_pool()
{
std::lock_guard<std::recursive_mutex> tp_lock(details::s_thread_pool_mutex);
details::s_thread_pool.reset();
}
} // namespace spdlog

@ -12,20 +12,6 @@
namespace spdlog {
// TODO what to do with flush_every ?
/*SPDLOG_INLINE void flush_every(std::chrono::seconds interval)
{
details::registry::instance().flush_every(interval);
}*/
SPDLOG_INLINE void shutdown()
{
// TODO call tp_ reset ?
//details::registry::instance().shutdown();
}
SPDLOG_INLINE std::shared_ptr<spdlog::logger>& default_logger()
{
static auto s_default_logger = stdout_color_mt("");
@ -37,10 +23,4 @@ SPDLOG_INLINE void set_default_logger(std::shared_ptr<spdlog::logger> new_logger
default_logger() = std::move(new_logger);
}
SPDLOG_INLINE logger *default_logger_raw()
{
return default_logger().get(); //TODO remove this
}
} // namespace spdlog

@ -35,10 +35,6 @@ inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs
return default_factory::create<Sink>(std::move(logger_name), std::forward<SinkArgs>(sink_args)...);
}
// stop any running threads started by spdlog for async logging
// TODO remove this
SPDLOG_API void shutdown();
// API for using default logger (stdout_color_mt),
// e.g: spdlog::info("Message {}", 1);
//

Loading…
Cancel
Save