5#ifndef SAPPHIRE_LOGGER_ASSERT_MACRO_GUARD
6#define SAPPHIRE_LOGGER_ASSERT_MACRO_GUARD
26 #define __SA_ASSERT(_exc)\
27 if (SA::Debug::logger)\
28 SA::Debug::logger->Assert(std::move(_exc));\
29 else if (SA::Debug::logCB)\
30 SA::Debug::logCB(_exc);\
32 std::cerr << "Try logging with invalid logger instance or callback! Initialize SA::Debug::logger or SA::Debug::logCB." << std::endl;
40 #define __SA_CREATE_EXCEPTION_TYPE(_chan, _dets, _type, ...) __SA_CREATE_EXCEPTION_##_type(\
41 (SA::Exception::BaseInfo{\
45 __SA_CHAN_NAME(_chan),\
52 #define __SA_CREATE_EXCEPTION(_type_params, _chan, _dets)\
53 __SA_EVAL_PASTE(__SA_CREATE_, EXCEPTION_TYPE(_chan, _dets, __SA_UNPARENT(_type_params)))
56 #define __SA_SELECT_ASSERT_MACRO(_1, _2, _3, _name, ...) _name
58 #define __SA_ASSERT3(_type_params, _chan, _dets){\
59 auto exc = __SA_CREATE_EXCEPTION(_type_params, _chan, SA::StringFormat(__SA_UNPARENT(_dets)));\
61 if(exc.level == SA::LogLevel::AssertFailure) throw exc;\
63 #define __SA_ASSERT2(_type_params, _chan) __SA_ASSERT3(_type_params, _chan, L"")
64 #define __SA_ASSERT1(_type_params) __SA_ASSERT2(_type_params, Default)
67 #define __SA_THROW3(_type_params, _chan, _dets){\
68 auto exc = __SA_CREATE_EXCEPTION(_type_params, _chan, SA::StringFormat(__SA_UNPARENT(_dets)));\
72 #define __SA_THROW2(_type_params, _chan) __SA_THROW3(_type_params, _chan, L"")
73 #define __SA_THROW1(_type_params) __SA_THROW2(_type_params, Default)
91 #define SA_THROW((_type, _params...), _chan, _dets)
105 #define SA_ASSERT((_type, _params...), _chan, _dets)
107#elif SA_DEBUG || SA_LOG_RELEASE_OPT
109 #define SA_THROW(...){ __SA_SELECT_ASSERT_MACRO(__VA_ARGS__, __SA_THROW3, __SA_THROW2, __SA_THROW1)(__VA_ARGS__) }
111 #define SA_ASSERT(...) { __SA_SELECT_ASSERT_MACRO(__VA_ARGS__, __SA_ASSERT3, __SA_ASSERT2, __SA_ASSERT1)(__VA_ARGS__) }
115 #define SA_THROW(...) {}
117 #define SA_ASSERT(...) {}
Log Helper Macros implementation.