Added custom error handler support to async sink

This commit is contained in:
gabime
2025-01-17 13:30:37 +02:00
parent b46b6dcb00
commit bc2eed7913
4 changed files with 23 additions and 6 deletions

View File

@@ -14,11 +14,15 @@
namespace spdlog {
namespace sinks {
async_sink::async_sink(config async_config)
: config_(std::move(async_config)) {
async_sink::async_sink(const config &async_config)
: config_(async_config) {
if (config_.queue_size == 0 || config_.queue_size > max_queue_size) {
throw spdlog_ex("async_sink: invalid queue size");
}
if (config_.custom_err_handler) {
err_helper_.set_err_handler(config_.custom_err_handler);
}
q_ = std::make_unique<queue_t>(config_.queue_size);
worker_thread_ = std::thread([this] {
if (config_.on_thread_start) config_.on_thread_start();