Removed tweak options and spdlog_config.h

This commit is contained in:
gabime
2024-11-30 19:55:45 +02:00
parent 21e0810791
commit 3c9963a495
14 changed files with 47 additions and 124 deletions

View File

@@ -23,7 +23,7 @@ spdlog::async_logger::async_logger(std::string logger_name,
// send the log message to the thread pool
void spdlog::async_logger::sink_it_(const details::log_msg &msg) {
SPDLOG_TRY {
try {
if (auto pool_ptr = thread_pool_.lock()) {
pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
} else {
@@ -35,7 +35,7 @@ void spdlog::async_logger::sink_it_(const details::log_msg &msg) {
// send flush request to the thread pool
void spdlog::async_logger::flush_() {
SPDLOG_TRY {
try {
if (auto pool_ptr = thread_pool_.lock()) {
pool_ptr->post_flush(shared_from_this(), overflow_policy_);
} else {
@@ -51,7 +51,7 @@ void spdlog::async_logger::flush_() {
void spdlog::async_logger::backend_sink_it_(const details::log_msg &msg) {
for (auto &sink : sinks_) {
if (sink->should_log(msg.log_level)) {
SPDLOG_TRY { sink->log(msg); }
try { sink->log(msg); }
SPDLOG_LOGGER_CATCH(msg.source)
}
}
@@ -63,7 +63,7 @@ void spdlog::async_logger::backend_sink_it_(const details::log_msg &msg) {
void spdlog::async_logger::backend_flush_() {
for (auto &sink : sinks_) {
SPDLOG_TRY { sink->flush(); }
try { sink->flush(); }
SPDLOG_LOGGER_CATCH(source_loc())
}
}

View File

@@ -33,8 +33,8 @@ spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) {
const char *spdlog_ex::what() const noexcept { return msg_.c_str(); }
void throw_spdlog_ex(const std::string &msg, int last_errno) { SPDLOG_THROW(spdlog_ex(msg, last_errno)); }
void throw_spdlog_ex(const std::string &msg, int last_errno) { throw(spdlog_ex(msg, last_errno)); }
void throw_spdlog_ex(std::string msg) { SPDLOG_THROW(spdlog_ex(std::move(msg))); }
void throw_spdlog_ex(std::string msg) { throw(spdlog_ex(std::move(msg))); }
} // namespace spdlog

View File

@@ -15,12 +15,13 @@ log_msg::log_msg(spdlog::log_clock::time_point log_time,
spdlog::string_view_t msg)
: logger_name(a_logger_name),
log_level(lvl),
time(log_time)
#ifndef SPDLOG_NO_THREAD_ID
,
thread_id(os::thread_id())
time(log_time),
#ifdef SPDLOG_NO_THREAD_ID
thread_id(0),
#else
thread_id(os::thread_id()),
#endif
,
source(loc),
payload(msg) {
}

View File

@@ -37,7 +37,7 @@ thread_pool::thread_pool(size_t q_max_items, size_t threads_n)
// message all threads to terminate gracefully join them
thread_pool::~thread_pool() {
SPDLOG_TRY {
try {
for (size_t i = 0; i < threads_.size(); i++) {
post_async_msg_(async_msg(async_msg_type::terminate), async_overflow_policy::block);
}
@@ -46,7 +46,7 @@ thread_pool::~thread_pool() {
t.join();
}
}
SPDLOG_CATCH_STD
catch (...) {}
}
void thread_pool::post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy) {

View File

@@ -75,7 +75,7 @@ std::shared_ptr<logger> logger::clone(std::string logger_name) {
// private/protected methods
void logger::flush_() {
for (auto &sink : sinks_) {
SPDLOG_TRY { sink->flush(); }
try { sink->flush(); }
SPDLOG_LOGGER_CATCH(source_loc())
}
}