File indexing completed on 2025-01-18 10:12:43
0001
0002
0003
0004 #pragma once
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <spdlog/logger.h>
0018
0019 namespace spdlog {
0020
0021
0022 enum class async_overflow_policy
0023 {
0024 block,
0025 overrun_oldest
0026
0027 };
0028
0029 namespace details {
0030 class thread_pool;
0031 }
0032
0033 class SPDLOG_API async_logger final : public std::enable_shared_from_this<async_logger>, public logger
0034 {
0035 friend class details::thread_pool;
0036
0037 public:
0038 template<typename It>
0039 async_logger(std::string logger_name, It begin, It end, std::weak_ptr<details::thread_pool> tp,
0040 async_overflow_policy overflow_policy = async_overflow_policy::block)
0041 : logger(std::move(logger_name), begin, end)
0042 , thread_pool_(std::move(tp))
0043 , overflow_policy_(overflow_policy)
0044 {}
0045
0046 async_logger(std::string logger_name, sinks_init_list sinks_list, std::weak_ptr<details::thread_pool> tp,
0047 async_overflow_policy overflow_policy = async_overflow_policy::block);
0048
0049 async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp,
0050 async_overflow_policy overflow_policy = async_overflow_policy::block);
0051
0052 std::shared_ptr<logger> clone(std::string new_name) override;
0053
0054 protected:
0055 void sink_it_(const details::log_msg &msg) override;
0056 void flush_() override;
0057 void backend_sink_it_(const details::log_msg &incoming_log_msg);
0058 void backend_flush_();
0059
0060 private:
0061 std::weak_ptr<details::thread_pool> thread_pool_;
0062 async_overflow_policy overflow_policy_;
0063 };
0064 }
0065
0066 #ifdef SPDLOG_HEADER_ONLY
0067 # include "async_logger-inl.h"
0068 #endif