3#define FMT_EXCEPTIONS 0
20template<
bool Ansi = true>
28 case LogInfo:
return "\033[37mI";
29 case LogWarn:
return "\033[33mW";
52template<
typename ...Args>
55 fmt::basic_memory_buffer<char, fmt::inline_buffer_size, Foundation::Core::StlDefaultAllocator<char>> buffer;
56 fmt::format_to(std::back_inserter(buffer), format, std::forward<Args>(args)...);
57 buffer.push_back(
'\0');
63 template <
typename... Args>
64 void Print(fmt::format_string<Args...> format, Args&&... args)
66 fmt::basic_memory_buffer<char, fmt::inline_buffer_size, StlDefaultAllocator<char>> buffer;
67 fmt::format_to(std::back_inserter(buffer), format, std::forward<Args>(args)...);
68 buffer.push_back(
'\0');
72 template <
typename... Args>
73 void Println(fmt::format_string<Args...> format, Args&&... args)
75 Print(format, std::forward<Args>(args)...);
80#define LOG(TAG, LEVEL, FORMAT, ...) Foundation_Log(#TAG, LEVEL, FORMAT __VA_OPT__(,) __VA_ARGS__);
83#define FOUNDATION_TRAP() __debugbreak()
84#elif defined(__clang__) && __has_builtin(__builtin_debugtrap)
85#define FOUNDATION_TRAP() __builtin_debugtrap()
87#define FOUNDATION_TRAP() __builtin_trap()
89#define FOUNDATION_STRINGIFY_2(x) #x
90#define FOUNDATION_STRINGIFY(x) FOUNDATION_STRINGIFY_2(x)
91#define FOUNDATION_SOURCE_LOC __FILE__ "@" FOUNDATION_STRINGIFY(__LINE__)
92#define CHECK(expr) do { \
93 if (!(expr)) [[unlikely]] { \
94 LOG(Core, LogError, "Check failed: {}", FOUNDATION_SOURCE_LOC ":" #expr); \
100#define CHECK_MSG(expr, format_str, ...) do { \
101 if (!(expr)) [[unlikely]] { \
102 LOG(Core, LogError, "Check failed: {}", FOUNDATION_SOURCE_LOC ":" #expr); \
103 LOG(Core, LogError, format_str __VA_OPT__(,) __VA_ARGS__); \
void Foundation_Log(const char *tag, LogLevel level, fmt::format_string< Args... > format, Args &&... args)
Definition Logging.hpp:53
void Foundation_LogImpl(LogLevel level, const char *tag, const char *formatted)
Definition Logging.cpp:7
void Foundation_PrintImpl(const char *formatted, bool flush)
Definition Logging.cpp:16
constexpr const char * format_as(LogLevel level)
Definition Logging.hpp:21
LogLevel
Definition Logging.hpp:13
@ LogWarn
Definition Logging.hpp:16
@ LogDebug
Definition Logging.hpp:14
@ LogError
Definition Logging.hpp:17
@ LogInfo
Definition Logging.hpp:15
void Foundation_PrintImpl(const char *formatted, bool flush)
Definition Logging.cpp:16
Lock-free atomic primitives and implementations of data structures.
Definition Allocator.hpp:6
void Println(fmt::format_string< Args... > format, Args &&... args)
Definition Logging.hpp:73
void Print(fmt::format_string< Args... > format, Args &&... args)
Definition Logging.hpp:64