2#include <UnCompute/Base/CompilerTraits.h>
3#include <UnCompute/Base/ResultCode.h>
6# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
16# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
22 assert(false && "Fatal error"); \
27#include <spdlog/spdlog.h>
31struct fmt::formatter<UN::ResultCode> : fmt::formatter<std::string_view>
33 template<
typename FormatContext>
34 auto format(
const UN::ResultCode& result, FormatContext& ctx)
const ->
decltype(ctx.out())
36 return fmt::format_to(ctx.out(),
"{}", UN::ResultToString(result));
45#define UNLOG_Debug(...) SPDLOG_DEBUG(__VA_ARGS__)
46#define UNLOG_Info(...) SPDLOG_INFO(__VA_ARGS__)
47#define UNLOG_Warning(...) SPDLOG_WARN(__VA_ARGS__)
48#define UNLOG_Error(...) SPDLOG_ERROR(__VA_ARGS__)
52#define UN_Verify(expr, ...) \
57 UNLOG_Error(__VA_ARGS__); \
66#define UN_VerifyResultFatal(expr, ...) \
69 if (auto resultCode = (expr); !::UN::Succeeded(resultCode)) \
71 UN_Verify(false, "[Result was {}]: {}", resultCode, ::fmt::format(__VA_ARGS__)); \
77#define UN_VerifyWarning(expr, ...) \
82 UNLOG_Warning(__VA_ARGS__); \
88#define UN_VerifyError(expr, ...) \
93 UNLOG_Error(__VA_ARGS__); \
101#define UN_VerifyResult(expr, ...) \
104 if (auto resultCode = (expr); !::UN::Succeeded(resultCode)) \
106 UN_VerifyError(false, "[Result was {}]: {}", resultCode, ::fmt::format(__VA_ARGS__)); \
111#if UN_DEBUG || defined DOXYGEN
113# define UN_Assert(expr, ...) UN_Verify(expr, __VA_ARGS__)
115# define UN_Warning(expr, ...) UN_VerifyWarning(expr, __VA_ARGS__)
117# define UN_Error(expr, ...) UN_VerifyError(expr, __VA_ARGS__)
119# define UN_Assert(expr, ...) UN_UNUSED(expr)
120# define UN_Warning(expr, ...) UN_UNUSED(expr)
121# define UN_Error(expr, ...) UN_UNUSED(expr)
127 inline void InitializeLogger()
129 spdlog::set_level(spdlog::level::debug);