48 | 48 |
}
|
49 | 49 |
|
50 | 50 |
template <bool bThrowException, typename... ArgsType>
|
51 | |
void LogError(const char* Function, const char* FullFilePath, int Line, const ArgsType&... Args)
|
|
51 |
void LogError(bool IsFatal, const char* Function, const char* FullFilePath, int Line, const ArgsType&... Args)
|
52 | 52 |
{
|
53 | 53 |
std::string FileName(FullFilePath);
|
54 | 54 |
|
|
58 | 58 |
auto Msg = FormatString(Args...);
|
59 | 59 |
if (DebugMessageCallback != nullptr)
|
60 | 60 |
{
|
61 | |
DebugMessageCallback(bThrowException ? DebugMessageSeverity::FatalError : DebugMessageSeverity::Error, Msg.c_str(), Function, FileName.c_str(), Line);
|
|
61 |
DebugMessageCallback(IsFatal ? DebugMessageSeverity::FatalError : DebugMessageSeverity::Error, Msg.c_str(), Function, FileName.c_str(), Line);
|
62 | 62 |
}
|
63 | 63 |
else
|
64 | 64 |
{
|
65 | 65 |
// No callback set - output to cerr
|
66 | |
std::cerr << "Diligent Engine: " << (bThrowException ? "Fatal Error" : "Error") << " in " << Function << "() (" << FileName << ", " << Line << "): " << Msg << '\n';
|
|
66 |
std::cerr << "Diligent Engine: " << (IsFatal ? "Fatal Error" : "Error") << " in " << Function << "() (" << FileName << ", " << Line << "): " << Msg << '\n';
|
67 | 67 |
}
|
68 | 68 |
ThrowIf<bThrowException>(std::move(Msg));
|
69 | 69 |
}
|
|
72 | 72 |
|
73 | 73 |
|
74 | 74 |
|
75 | |
#define LOG_ERROR(...) \
|
76 | |
do \
|
77 | |
{ \
|
78 | |
Diligent::LogError<false>(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
|
75 |
#define LOG_ERROR(...) \
|
|
76 |
do \
|
|
77 |
{ \
|
|
78 |
Diligent::LogError<false>(/*IsFatal=*/false, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
79 | 79 |
} while (false)
|
80 | 80 |
|
|
81 |
|
|
82 |
#define LOG_FATAL_ERROR(...) \
|
|
83 |
do \
|
|
84 |
{ \
|
|
85 |
Diligent::LogError<false>(/*IsFatal=*/true, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
|
86 |
} while (false)
|
81 | 87 |
|
82 | 88 |
#define LOG_ERROR_ONCE(...) \
|
83 | 89 |
do \
|
|
91 | 97 |
} while (false)
|
92 | 98 |
|
93 | 99 |
|
94 | |
#define LOG_ERROR_AND_THROW(...) \
|
95 | |
do \
|
96 | |
{ \
|
97 | |
Diligent::LogError<true>(__FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
|
100 |
#define LOG_ERROR_AND_THROW(...) \
|
|
101 |
do \
|
|
102 |
{ \
|
|
103 |
Diligent::LogError<true>(/*IsFatal=*/false, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
|
104 |
} while (false)
|
|
105 |
|
|
106 |
#define LOG_FATAL_ERROR_AND_THROW(...) \
|
|
107 |
do \
|
|
108 |
{ \
|
|
109 |
Diligent::LogError<true>(/*IsFatal=*/true, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__); \
|
98 | 110 |
} while (false)
|
99 | 111 |
|
100 | 112 |
|
|
105 | 117 |
if (Diligent::DebugMessageCallback != nullptr) Diligent::DebugMessageCallback(Severity, _msg.c_str(), nullptr, nullptr, 0); \
|
106 | 118 |
} while (false)
|
107 | 119 |
|
108 | |
#define LOG_ERROR_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
|
109 | |
#define LOG_WARNING_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
|
110 | |
#define LOG_INFO_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
|
|
120 |
#define LOG_FATAL_ERROR_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::FatalError, ##__VA_ARGS__)
|
|
121 |
#define LOG_ERROR_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
|
|
122 |
#define LOG_WARNING_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
|
|
123 |
#define LOG_INFO_MESSAGE(...) LOG_DEBUG_MESSAGE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
|
111 | 124 |
|
112 | 125 |
|
113 | 126 |
#define LOG_DEBUG_MESSAGE_ONCE(Severity, ...) \
|
|
121 | 134 |
} \
|
122 | 135 |
} while (false)
|
123 | 136 |
|
124 | |
#define LOG_ERROR_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
|
125 | |
#define LOG_WARNING_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
|
126 | |
#define LOG_INFO_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
|
|
137 |
#define LOG_FATAL_ERROR_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::FatalError, ##__VA_ARGS__)
|
|
138 |
#define LOG_ERROR_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
|
|
139 |
#define LOG_WARNING_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
|
|
140 |
#define LOG_INFO_MESSAGE_ONCE(...) LOG_DEBUG_MESSAGE_ONCE(Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
|
127 | 141 |
|
128 | 142 |
|
129 | 143 |
#define CHECK(Expr, Severity, ...) \
|
|
135 | 149 |
} \
|
136 | 150 |
} while (false)
|
137 | 151 |
|
138 | |
#define CHECK_ERR(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
|
139 | |
#define CHECK_WARN(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
|
140 | |
#define CHECK_INFO(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
|
|
152 |
#define CHECK_FATAL_ERR(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::FatalError, ##__VA_ARGS__)
|
|
153 |
#define CHECK_ERR(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Error, ##__VA_ARGS__)
|
|
154 |
#define CHECK_WARN(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Warning, ##__VA_ARGS__)
|
|
155 |
#define CHECK_INFO(Expr, ...) CHECK(Expr, Diligent::DebugMessageSeverity::Info, ##__VA_ARGS__)
|
141 | 156 |
|
142 | 157 |
#define CHECK_THROW(Expr, ...) \
|
143 | 158 |
do \
|