Commit e9635c7b authored by gabime's avatar gabime

rethrnow non std exceptions to fix #533

parent 8e3b1338
......@@ -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 {
......
......@@ -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)
......
......@@ -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<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)...);
}
// 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>
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)...);
}
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)...);
}
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)...);
}
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)...);
}
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)...);
}
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)...);
}
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)...);
}
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)...);
}
......@@ -225,7 +226,7 @@ public:
#else
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 traceback_enabled = tracer_.enabled();
......@@ -326,7 +327,7 @@ protected:
// common implementation for after templated public api has been resolved
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 traceback_enabled = tracer_.enabled();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment