chore: Move logging to where the messages get popped from queue

pull/2483/head
Aleksandar Levic 3 years ago
parent 05d4ec4eb7
commit ec7ca244ff

@ -62,16 +62,6 @@ SPDLOG_INLINE void spdlog::async_logger::backend_sink_it_(const details::log_msg
SPDLOG_TRY
{
sink->log(msg);
if (auto pool_ptr = thread_pool_.lock())
{
auto lost_messages = pool_ptr->overrun_counter();
if (lost_messages > 0) {
sink->log(details::log_msg{name(), level::warn, fmt::format("Lost {} messages", lost_messages)});
sink->flush();
pool_ptr->reset_overrun_counter();
}
}
}
SPDLOG_LOGGER_CATCH(msg.source)
}

@ -117,6 +117,13 @@ bool SPDLOG_INLINE thread_pool::process_next_msg_()
switch (incoming_async_msg.msg_type)
{
case async_msg_type::log: {
auto lost_messages = overrun_counter();
if (lost_messages > 0)
{
incoming_async_msg.worker_ptr->backend_sink_it_(
details::log_msg{incoming_async_msg.worker_ptr->name(), level::debug, fmt::format("Lost {} messages", lost_messages)});
reset_overrun_counter();
}
incoming_async_msg.worker_ptr->backend_sink_it_(incoming_async_msg);
return true;
}

Loading…
Cancel
Save