25#ifndef JPL_ERROR_REPORTING_DEFINED
26#define JPL_ERROR_REPORTING_DEFINED
30#ifdef JPL_TAGGED_LOGGING
35#include <source_location>
40#ifdef JPL_TAGGED_LOGGING
41 using TaggedTraceFunction = void (*)(std::string_view tag, std::string_view message);
42 JPL_EXPORT extern TaggedTraceFunction JPLTraceTaggedTrace;
43 JPL_EXPORT extern TaggedTraceFunction JPLTraceTaggedInfo;
44 JPL_EXPORT extern TaggedTraceFunction JPLTraceTaggedWarn;
45 JPL_EXPORT extern TaggedTraceFunction JPLTraceTaggedError;
53#ifndef JPL_ENABLE_ASSERTS
54#define JPL_ENABLE_ASSERTS
56#if !defined (JPL_TEST) && !defined(JPL_ENABLE_ENSURE)
57#define JPL_ENABLE_ENSURE
61#if defined(JPL_ENABLE_ASSERTS) || defined(JPL_ENABLE_ENSURE)
63using AssertFailedFunction = bool(*)(
const char* inExpression,
const char* inMessage,
const std::source_location);
78#ifdef JPL_ENABLE_ASSERTS
80#define JPL_ASSERT(inExpression, ...) do { if (!(inExpression) && ::JPL::AssertFailedParamHelper(#inExpression, std::source_location::current(), ##__VA_ARGS__)) JPL_BREAKPOINT; } while (false)
82#define JPL_IF_ENABLE_ASSERTS(...) __VA_ARGS__
84#define JPL_ASSERT(...) ((void)0)
86#define JPL_IF_ENABLE_ASSERTS(...)
92#ifdef JPL_ENABLE_ENSURE
94#define JPL_ENSURE(inExpression, ...) [&]{ if(!(inExpression) && ::JPL::AssertFailedParamHelper(#inExpression, std::source_location::current(), ##__VA_ARGS__)) { JPL_BREAKPOINT; } return (inExpression); }()
96#define JPL_ENSURE(inExpression, ...) (inExpression)
101 #ifdef JPL_TAGGED_LOGGING
102 #define JPL_TRACE_TAG(tag, message) JPLTraceTaggedTrace(tag, message)
104 #define JPL_TRACE_TAG(tag, message) SpatialTrace(std::format("[{}]: Trace: {}", tag, message).c_str())
109 #ifdef JPL_TAGGED_LOGGING
110 #define JPL_INFO_TAG(tag, message) JPLTraceTaggedInfo(tag, message)
112 #define JPL_INFO_TAG(tag, message) SpatialTrace(std::format("[{}]: Info: {}", tag, message).c_str())
117 #ifdef JPL_TAGGED_LOGGING
118 #define JPL_WARN_TAG(tag, message) JPLTraceTaggedWarn(tag, message)
120 #define JPL_WARN_TAG(tag, message) SpatialTrace(std::format("[{}]: Warning: {}", tag, message).c_str())
125 #ifdef JPL_TAGGED_LOGGING
126 #define JPL_ERROR_TAG(tag, message) JPLTraceTaggedError(tag, message)
128 #define JPL_ERROR_TAG(tag, message) SpatialTrace(std::format("[{}]: Error: {}", tag, message).c_str())
#define JPL_EXPORT
Definition Core.h:235
Definition AcousticMaterial.h:36
bool AssertFailedParamHelper(const char *inExpression, const std::source_location location)
Definition ErrorReporting.h:67
bool(*)(const char *inExpression, const char *inMessage, const std::source_location) AssertFailedFunction
Function called when an assertion fails. This function should return true if a breakpoint needs to be...
Definition ErrorReporting.h:63
void(*)(const char *message) TraceFunction
Trace function, needs to be overridden by application. This should output a line of text to the log /...
Definition ErrorReporting.h:47
JPL_EXPORT TraceFunction SpatialTrace
JPL_EXPORT AssertFailedFunction AssertFailed