2020-07-16 21:48:33 +02:00
|
|
|
#pragma once
|
|
|
|
#if _DEBUG
|
|
|
|
constexpr bool DebugBuild = true;
|
|
|
|
#else
|
|
|
|
constexpr bool DebugBuild = false;
|
|
|
|
#endif
|
|
|
|
#include <stdexcept>
|
2021-08-03 15:08:43 +01:00
|
|
|
#include <string_view>
|
2020-07-16 21:48:33 +02:00
|
|
|
|
2020-07-18 07:01:34 +02:00
|
|
|
inline void assertion(const bool& expr,const char* msg) noexcept {
|
2020-07-16 21:48:33 +02:00
|
|
|
if constexpr (DebugBuild) {
|
|
|
|
if (!expr) throw std::runtime_error(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template <typename ...T>
|
|
|
|
inline void logD(const T&... x) {
|
|
|
|
if constexpr (DebugBuild) {
|
|
|
|
(std::cout << ... << x) << std::endl;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename ...T>
|
|
|
|
inline void logE(const T&... x) {
|
|
|
|
if constexpr (DebugBuild) {
|
|
|
|
(std::cerr << ... << x) << std::endl;
|
|
|
|
}
|
2021-08-03 15:08:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class LogLevel
|
|
|
|
{
|
|
|
|
Error,
|
|
|
|
Warning,
|
|
|
|
Info
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class LogConfig
|
|
|
|
{
|
|
|
|
Debug,
|
|
|
|
All
|
|
|
|
};
|
|
|
|
|
|
|
|
void TENLog(std::string_view str, LogLevel level = LogLevel::Info, LogConfig config = LogConfig::Debug);
|
|
|
|
|
|
|
|
class TENScriptException : public std::runtime_error
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using std::runtime_error::runtime_error;
|
2020-07-16 21:48:33 +02:00
|
|
|
};
|