diff --git a/include/spdlog/common.h b/include/spdlog/common.h index fb9a3660..95f3719e 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -71,11 +71,12 @@ printf("spdlog fatal error: %s\n", ex.what()); \ std::abort(); \ } while (0) -#define SPDLOG_CATCH_ALL() +#define SPDLOG_CATCH_STD #else #define SPDLOG_TRY try #define SPDLOG_THROW(ex) throw(ex) -#define SPDLOG_CATCH_ALL() catch (...) +#define SPDLOG_CATCH_STD \ + catch (const std::exception &) {} #endif namespace spdlog { diff --git a/include/spdlog/details/thread_pool-inl.h b/include/spdlog/details/thread_pool-inl.h index c1df4361..a0c8a222 100644 --- a/include/spdlog/details/thread_pool-inl.h +++ b/include/spdlog/details/thread_pool-inl.h @@ -49,7 +49,7 @@ SPDLOG_INLINE thread_pool::~thread_pool() t.join(); } } - SPDLOG_CATCH_ALL() {} + SPDLOG_CATCH_STD } void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index a34c5221..28e7dffd 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -31,7 +31,8 @@ } \ catch (...) \ { \ - err_handler_("Unknown exception in logger"); \ + err_handler_("Rethrowing unknown exception in logger"); \ + throw; \ } #else #define SPDLOG_LOGGER_CATCH() @@ -75,56 +76,56 @@ public: // FormatString is a type derived from fmt::compile_string template::value, int>::type = 0, typename... Args> - void log(source_loc loc, level::level_enum lvl, const FormatString &fmt, Args&&...args) + void log(source_loc loc, level::level_enum lvl, const FormatString &fmt, Args &&...args) { log_(loc, lvl, fmt, std::forward(args)...); } // FormatString is NOT a type derived from fmt::compile_string but is a string_view_t or can be implicitly converted to one template - void log(source_loc loc, level::level_enum lvl, string_view_t fmt, Args&&...args) + void log(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&...args) { log_(loc, lvl, fmt, std::forward(args)...); } template - void log(level::level_enum lvl, const FormatString &fmt, Args&&...args) + void log(level::level_enum lvl, const FormatString &fmt, Args &&...args) { log(source_loc{}, lvl, fmt, std::forward(args)...); } template - void trace(const FormatString &fmt, Args&&...args) + void trace(const FormatString &fmt, Args &&...args) { log(level::trace, fmt, std::forward(args)...); } template - void debug(const FormatString &fmt, Args&&...args) + void debug(const FormatString &fmt, Args &&...args) { log(level::debug, fmt, std::forward(args)...); } template - void info(const FormatString &fmt, Args&&...args) + void info(const FormatString &fmt, Args &&...args) { log(level::info, fmt, std::forward(args)...); } template - void warn(const FormatString &fmt, Args&&...args) + void warn(const FormatString &fmt, Args &&...args) { log(level::warn, fmt, std::forward(args)...); } template - void error(const FormatString &fmt, Args&&...args) + void error(const FormatString &fmt, Args &&...args) { log(level::err, fmt, std::forward(args)...); } template - void critical(const FormatString &fmt, Args&&...args) + void critical(const FormatString &fmt, Args &&...args) { log(level::critical, fmt, std::forward(args)...); } @@ -225,7 +226,7 @@ public: #else template - void log(source_loc loc, level::level_enum lvl, wstring_view_t fmt, Args&&...args) + void log(source_loc loc, level::level_enum lvl, wstring_view_t fmt, Args &&...args) { bool log_enabled = should_log(lvl); bool traceback_enabled = tracer_.enabled(); @@ -326,7 +327,7 @@ protected: // common implementation for after templated public api has been resolved template - void log_(source_loc loc, level::level_enum lvl, const FormatString &fmt, Args&&...args) + void log_(source_loc loc, level::level_enum lvl, const FormatString &fmt, Args &&...args) { bool log_enabled = should_log(lvl); bool traceback_enabled = tracer_.enabled();