diff --git a/include/spdlog/async_logger-inl.h b/include/spdlog/async_logger-inl.h index 6fac8fc9..9f94d14f 100644 --- a/include/spdlog/async_logger-inl.h +++ b/include/spdlog/async_logger-inl.h @@ -62,7 +62,7 @@ SPDLOG_INLINE void spdlog::async_logger::backend_sink_it_(const details::log_msg { sink->log(msg); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH(msg.payload) } } @@ -80,7 +80,7 @@ SPDLOG_INLINE void spdlog::async_logger::backend_flush_() { sink->flush(); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH("") } } diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index fd841657..c44caff3 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -185,7 +185,7 @@ SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg) { sink->log(msg); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH(msg.payload) } } @@ -203,7 +203,7 @@ SPDLOG_INLINE void logger::flush_() { sink->flush(); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH("") } } diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index ff3bef58..43ac4fb4 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -28,10 +28,10 @@ #include #ifndef SPDLOG_NO_EXCEPTIONS -# define SPDLOG_LOGGER_CATCH() \ +# define SPDLOG_LOGGER_CATCH(additional_info) \ catch (const std::exception &ex) \ { \ - err_handler_(ex.what()); \ + err_handler_(fmt::format("{} ({})", ex.what(), additional_info)); \ } \ catch (...) \ { \ @@ -39,7 +39,7 @@ throw; \ } #else -# define SPDLOG_LOGGER_CATCH() +# define SPDLOG_LOGGER_CATCH(additional_info) #endif namespace spdlog { @@ -333,7 +333,7 @@ protected: details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size())); log_it_(log_msg, log_enabled, traceback_enabled); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH(fmt) } #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT @@ -356,7 +356,7 @@ protected: details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size())); log_it_(log_msg, log_enabled, traceback_enabled); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH(fmt) } // T can be statically converted to wstring_view, and no formatting needed. @@ -376,7 +376,7 @@ protected: details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size())); log_it_(log_msg, log_enabled, traceback_enabled); } - SPDLOG_LOGGER_CATCH() + SPDLOG_LOGGER_CATCH(msg) } #endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT