rethrnow non std exceptions to fix #533

This commit is contained in:
gabime 2021-05-01 00:29:36 +03:00
parent 8e3b1338a5
commit e9635c7b2d
3 changed files with 17 additions and 15 deletions

View File

@ -71,11 +71,12 @@
printf("spdlog fatal error: %s\n", ex.what()); \ printf("spdlog fatal error: %s\n", ex.what()); \
std::abort(); \ std::abort(); \
} while (0) } while (0)
#define SPDLOG_CATCH_ALL() #define SPDLOG_CATCH_STD
#else #else
#define SPDLOG_TRY try #define SPDLOG_TRY try
#define SPDLOG_THROW(ex) throw(ex) #define SPDLOG_THROW(ex) throw(ex)
#define SPDLOG_CATCH_ALL() catch (...) #define SPDLOG_CATCH_STD \
catch (const std::exception &) {}
#endif #endif
namespace spdlog { namespace spdlog {

View File

@ -49,7 +49,7 @@ SPDLOG_INLINE thread_pool::~thread_pool()
t.join(); 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) void SPDLOG_INLINE thread_pool::post_log(async_logger_ptr &&worker_ptr, const details::log_msg &msg, async_overflow_policy overflow_policy)

View File

@ -31,7 +31,8 @@
} \ } \
catch (...) \ catch (...) \
{ \ { \
err_handler_("Unknown exception in logger"); \ err_handler_("Rethrowing unknown exception in logger"); \
throw; \
} }
#else #else
#define SPDLOG_LOGGER_CATCH() #define SPDLOG_LOGGER_CATCH()
@ -75,56 +76,56 @@ public:
// FormatString is a type derived from fmt::compile_string // FormatString is a type derived from fmt::compile_string
template<typename FormatString, typename std::enable_if<fmt::is_compile_string<FormatString>::value, int>::type = 0, typename... Args> template<typename FormatString, typename std::enable_if<fmt::is_compile_string<FormatString>::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>(args)...); log_(loc, lvl, fmt, std::forward<Args>(args)...);
} }
// FormatString is NOT a type derived from fmt::compile_string but is a string_view_t or can be implicitly converted to one // FormatString is NOT a type derived from fmt::compile_string but is a string_view_t or can be implicitly converted to one
template<typename... Args> template<typename... Args>
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>(args)...); log_(loc, lvl, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
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>(args)...); log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
void trace(const FormatString &fmt, Args&&...args) void trace(const FormatString &fmt, Args &&...args)
{ {
log(level::trace, fmt, std::forward<Args>(args)...); log(level::trace, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
void debug(const FormatString &fmt, Args&&...args) void debug(const FormatString &fmt, Args &&...args)
{ {
log(level::debug, fmt, std::forward<Args>(args)...); log(level::debug, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
void info(const FormatString &fmt, Args&&...args) void info(const FormatString &fmt, Args &&...args)
{ {
log(level::info, fmt, std::forward<Args>(args)...); log(level::info, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
void warn(const FormatString &fmt, Args&&...args) void warn(const FormatString &fmt, Args &&...args)
{ {
log(level::warn, fmt, std::forward<Args>(args)...); log(level::warn, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
void error(const FormatString &fmt, Args&&...args) void error(const FormatString &fmt, Args &&...args)
{ {
log(level::err, fmt, std::forward<Args>(args)...); log(level::err, fmt, std::forward<Args>(args)...);
} }
template<typename FormatString, typename... Args> template<typename FormatString, typename... Args>
void critical(const FormatString &fmt, Args&&...args) void critical(const FormatString &fmt, Args &&...args)
{ {
log(level::critical, fmt, std::forward<Args>(args)...); log(level::critical, fmt, std::forward<Args>(args)...);
} }
@ -225,7 +226,7 @@ public:
#else #else
template<typename... Args> template<typename... Args>
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 log_enabled = should_log(lvl);
bool traceback_enabled = tracer_.enabled(); bool traceback_enabled = tracer_.enabled();
@ -326,7 +327,7 @@ protected:
// common implementation for after templated public api has been resolved // common implementation for after templated public api has been resolved
template<typename FormatString, typename... Args> template<typename FormatString, 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)
{ {
bool log_enabled = should_log(lvl); bool log_enabled = should_log(lvl);
bool traceback_enabled = tracer_.enabled(); bool traceback_enabled = tracer_.enabled();