| 38 | { |
| 39 | template<typename Sink, typename... SinkArgs> |
| 40 | static std::shared_ptr<async_logger> create(std::string logger_name, SinkArgs &&... args) |
| 41 | { |
| 42 | auto ®istry_inst = details::registry::instance(); |
| 43 | |
| 44 | // create global thread pool if not already exists.. |
| 45 | std::lock_guard<std::recursive_mutex> tp_lock(registry_inst.tp_mutex()); |
| 46 | auto tp = registry_inst.get_tp(); |
| 47 | if (tp == nullptr) |
| 48 | { |
| 49 | tp = std::make_shared<details::thread_pool>(details::default_async_q_size, 1); |
| 50 | registry_inst.set_tp(tp); |
| 51 | } |
| 52 | |
| 53 | auto sink = std::make_shared<Sink>(std::forward<SinkArgs>(args)...); |
| 54 | auto new_logger = std::make_shared<async_logger>(std::move(logger_name), std::move(sink), std::move(tp), OverflowPolicy); |
| 55 | registry_inst.initialize_logger(new_logger); |
| 56 | return new_logger; |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | using async_factory = async_factory_impl<async_overflow_policy::block>; |
nothing calls this directly
no test coverage detected