A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Logger.hh
1#pragma once
2
3#include <cstdio>
4#include <cstdlib>
5
6#define TOSTRINGIMPL(x) #x
7#define TOSTRING(x) TOSTRINGIMPL(x)
8
9#ifdef __FILE_NAME__
10#define FILE_NAME __FILE_NAME__
11#else
12#define FILE_NAME __FILE__
13#endif
14
15#define STATIC_ASSERT(e) static_assert(e, "[" FILE_NAME ":" TOSTRING(__LINE__) "] ASSERT: " #e)
16
17#define RUNTIME_ASSERT(e) \
18 do { \
19 if (!(e)) { \
20 printf("[" FILE_NAME ":" TOSTRING(__LINE__) "] ASSERT: " #e "\n"); \
21 abort(); \
22 } \
23 } while (0)
24
25#define ASSERT(e) RUNTIME_ASSERT(e)
26
27#define PANIC(m, ...) \
28 do { \
29 printf("[" FILE_NAME ":" TOSTRING(__LINE__) "] PANIC: " m "\n", ##__VA_ARGS__); \
30 abort(); \
31 } while (0)
32
33#define WARN(m, ...) \
34 do { \
35 printf("[" FILE_NAME ":" TOSTRING(__LINE__) "] WARN: " m "\n\n", ##__VA_ARGS__); \
36 } while (0)
37
38#define REPORT(m, ...) \
39 do { \
40 printf("[" FILE_NAME ":" TOSTRING(__LINE__) "] REPORT: " m "\n", ##__VA_ARGS__); \
41 } while (0)
42
43#ifdef BUILD_DEBUG
44#define DEBUG(m, ...) \
45 do { \
46 printf("[" FILE_NAME ":" TOSTRING(__LINE__) "] DEBUG: " m "\n", ##__VA_ARGS__); \
47 } while (0)
48#else
49#define DEBUG(m, ...)
50#endif