This commit is contained in:
Denis Ivaykin 2015-01-14 15:39:11 -06:00
parent 365d895482
commit 295e189b7e
3 changed files with 12 additions and 11 deletions

View File

@ -126,8 +126,8 @@ private:
// last exception thrown from the worker thread
std::shared_ptr<spdlog_ex> _last_workerthread_ex;
// overflow policy
const async_queue_overflow_policy _overflow_policy;
// overflow policy
const async_queue_overflow_policy _overflow_policy;
// worker thread warmup callback - one can set thread priority, affinity, etc
const std::function<void()> _worker_warmup_cb;
@ -157,7 +157,7 @@ inline spdlog::details::async_log_helper::async_log_helper(formatter_ptr formatt
_formatter(formatter),
_sinks(sinks),
_q(queue_size),
_overflow_policy(overflow_policy),
_overflow_policy(overflow_policy),
_worker_warmup_cb(worker_warmup_cb),
_worker_thread(&async_log_helper::worker_loop, this)
{}

View File

@ -125,8 +125,8 @@ public:
std::lock_guard<std::mutex> lock(_mutex);
_async_mode = true;
_async_q_size = q_size;
_overflow_policy = overflow_policy;
_worker_warmup_cb = worker_warmup_cb;
_overflow_policy = overflow_policy;
_worker_warmup_cb = worker_warmup_cb;
}
void set_sync_mode()
@ -152,8 +152,8 @@ private:
level::level_enum _level = level::info;
bool _async_mode = false;
size_t _async_q_size = 0;
async_queue_overflow_policy _overflow_policy = async_queue_overflow_policy::block_retry;
std::function<void()> _worker_warmup_cb = nullptr;
async_queue_overflow_policy _overflow_policy = async_queue_overflow_policy::block_retry;
std::function<void()> _worker_warmup_cb = nullptr;
};
}
}

View File

@ -61,9 +61,10 @@ void set_level(level::level_enum log_level);
// Async mode - off by default.
//
enum class async_queue_overflow_policy {
block_retry, // Block / yield / sleep until message can be enqueued
discard_log_msg // Discard the message it enqueue fails
enum class async_queue_overflow_policy
{
block_retry, // Block / yield / sleep until message can be enqueued
discard_log_msg // Discard the message it enqueue fails
};
// Turn on async mode and set the queue size for each async_logger