50 log_clock::time_point
time;
61 logger_name(
std::
move(other.logger_name)),
64 thread_id(other.thread_id),
66 msg_type(
std::
move(other.msg_type)),
79 logger_name =
std::move(other.logger_name);
82 thread_id = other.thread_id;
84 msg_type = other.msg_type;
85 msg_id = other.msg_id;
97 thread_id(m.thread_id),
98 txt(m.raw.data(), m.raw.size()),
102 #ifndef SPDLOG_NO_NAME 125 using clock = std::chrono::steady_clock;
129 const std::vector<sink_ptr>& sinks,
133 const std::function<
void()>& worker_warmup_cb =
nullptr,
134 const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(),
135 const std::function<
void()>& worker_teardown_cb =
nullptr);
144 void flush(
bool wait_for_q);
150 std::vector<std::shared_ptr<sinks::sink>>
_sinks;
184 bool process_next_msg(log_clock::time_point& last_pop, log_clock::time_point& last_flush);
189 static void sleep_or_yield(
const spdlog::log_clock::time_point&
now,
const log_clock::time_point& last_op_time);
203 const std::vector<sink_ptr>& sinks,
207 const std::function<
void()>& worker_warmup_cb,
208 const std::chrono::milliseconds& flush_interval_ms,
209 const std::function<
void()>& worker_teardown_cb):
249 auto now = last_op_time;
271 auto last_flush = last_pop;
279 catch (
const std::exception &ex)
302 switch (incoming_async_msg.
msg_type)
319 if (
s->should_log(incoming_log_msg.
level))
321 s->log(incoming_log_msg);
361 using namespace std::this_thread;
362 using std::chrono::milliseconds;
363 using std::chrono::microseconds;
365 auto time_since_op = now - last_op_time;
368 if (time_since_op <= microseconds(50))
372 if (time_since_op <= microseconds(100))
373 return std::this_thread::yield();
376 if (time_since_op <= milliseconds(200))
377 return sleep_for(milliseconds(20));
380 return sleep_for(milliseconds(200));
static void sleep_or_yield(const spdlog::log_clock::time_point &now, const log_clock::time_point &last_op_time)
void fill_log_msg(log_msg &msg)
const async_overflow_policy _overflow_policy
void log(const details::log_msg &msg)
const std::string * logger_name
bool process_next_msg(log_clock::time_point &last_pop, log_clock::time_point &last_flush)
void handle_flush_interval(log_clock::time_point &now, log_clock::time_point &last_flush)
async_msg & operator=(async_msg &&other) SPDLOG_NOEXCEPT
std::shared_ptr< spdlog::formatter > formatter_ptr
async_msg(async_msg &&other) SPDLOG_NOEXCEPT
std::vector< std::shared_ptr< sinks::sink > > _sinks
void set_error_handler(spdlog::log_err_handler err_handler)
spdlog::log_clock::time_point now()
const std::function< void()> _worker_teardown_cb
std::chrono::steady_clock clock
fmt::BufferedFile & move(fmt::BufferedFile &f)
log_clock::time_point time
void flush(bool wait_for_q)
std::thread _worker_thread
void set_formatter(formatter_ptr)
bool _terminate_requested
async_msg(const details::log_msg &m)
log_err_handler _err_handler
const std::chrono::milliseconds _flush_interval_ms
async_msg(async_msg_type m_type)
void push_msg(async_msg &&new_msg)
std::function< void(const std::string &err_msg)> log_err_handler
log_clock::time_point time
async_log_helper(formatter_ptr formatter, const std::vector< sink_ptr > &sinks, size_t queue_size, const log_err_handler err_handler, const async_overflow_policy overflow_policy=async_overflow_policy::block_retry, const std::function< void()> &worker_warmup_cb=nullptr, const std::chrono::milliseconds &flush_interval_ms=std::chrono::milliseconds::zero(), const std::function< void()> &worker_teardown_cb=nullptr)
const std::function< void()> _worker_warmup_cb