Some fixes for logging, added MIJIN_LOG_IF and the DebugOutputLogSink.
This commit is contained in:
@@ -254,10 +254,14 @@ MIJIN_DEFINE_LOG_LEVEL(ERROR, MIJIN_LOG_LEVEL_VALUE_ERROR)
|
||||
#define MIJIN_LOG_ALWAYS(level, channel, ...) MIJIN_FUNCNAME_GET_LOGGER().log( \
|
||||
MIJIN_LOG_LEVEL_OBJECT(level), MIJIN_LOG_CHANNEL_OBJECT(channel), std::source_location::current(), __VA_ARGS__ \
|
||||
)
|
||||
#define MIJIN_LOG(level, channel, ...) \
|
||||
#define MIJIN_LOG(level, channel, ...) \
|
||||
if constexpr (MIJIN_LOG_LEVEL_OBJECT(level).value < MIJIN_FUNCNAME_MIN_LOG_LEVEL_COMPILE()) {} \
|
||||
else MIJIN_LOG_ALWAYS(level, channel, __VA_ARGS__)
|
||||
|
||||
#define MIJIN_LOG_IF(cond, level, channel, ...) \
|
||||
if constexpr (MIJIN_LOG_LEVEL_OBJECT(level).value < MIJIN_FUNCNAME_MIN_LOG_LEVEL_COMPILE()) {} \
|
||||
else if (cond) MIJIN_LOG_ALWAYS(level, channel, __VA_ARGS__)
|
||||
|
||||
#define MIJIN_SET_CLASS_LOGGER(loggerExpr) \
|
||||
const auto& MIJIN_FUNCNAME_GET_LOGGER() const noexcept \
|
||||
{ \
|
||||
@@ -268,6 +272,11 @@ auto MIJIN_FUNCNAME_GET_LOGGER = [&]() -> const auto& \
|
||||
{ \
|
||||
return loggerExpr; \
|
||||
};
|
||||
#define MIJIN_SET_NS_LOGGER(loggerExpr) \
|
||||
inline const mijin::Logger& MIJIN_FUNCNAME_GET_LOGGER() \
|
||||
{ \
|
||||
return loggerExpr; \
|
||||
}
|
||||
#define MIJIN_SET_CLASS_MIN_LOG_LEVEL_COMPILE(level) \
|
||||
int MIJIN_FUNCNAME_MIN_LOG_LEVEL_COMPILE() MIJIN_NOEXCEPT \
|
||||
{ \
|
||||
|
||||
Reference in New Issue
Block a user