29 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
30 #include <SDL_assert.h>
36 #define logStr(category, msg) \
38 message.append(msg); \
42 #if !SDL_VERSION_ATLEAST(2, 0, 4)
43 #define SDL_AssertState SDL_assert_state
44 #define SDL_AssertData SDL_assert_data
47 static void logCallback(
void *userData
A_UNUSED,
49 SDL_LogPriority priority,
52 std::string message(
"SDL ERROR:");
55 logStr(SDL_LOG_PRIORITY_VERBOSE,
57 logStr(SDL_LOG_PRIORITY_DEBUG,
59 logStr(SDL_LOG_PRIORITY_INFO,
61 logStr(SDL_LOG_PRIORITY_WARN,
63 logStr(SDL_LOG_PRIORITY_ERROR,
65 logStr(SDL_LOG_PRIORITY_CRITICAL,
67 case SDL_NUM_LOG_PRIORITIES:
75 logStr(SDL_LOG_CATEGORY_APPLICATION,
77 logStr(SDL_LOG_CATEGORY_ERROR,
79 logStr(SDL_LOG_CATEGORY_ASSERT,
81 logStr(SDL_LOG_CATEGORY_SYSTEM,
83 logStr(SDL_LOG_CATEGORY_AUDIO,
85 logStr(SDL_LOG_CATEGORY_VIDEO,
87 logStr(SDL_LOG_CATEGORY_RENDER,
89 logStr(SDL_LOG_CATEGORY_INPUT,
91 logStr(SDL_LOG_CATEGORY_TEST,
93 logStr(SDL_LOG_CATEGORY_RESERVED1,
95 logStr(SDL_LOG_CATEGORY_RESERVED2,
97 logStr(SDL_LOG_CATEGORY_RESERVED3,
99 logStr(SDL_LOG_CATEGORY_RESERVED4,
101 logStr(SDL_LOG_CATEGORY_RESERVED5,
103 logStr(SDL_LOG_CATEGORY_RESERVED6,
105 logStr(SDL_LOG_CATEGORY_RESERVED7,
107 logStr(SDL_LOG_CATEGORY_RESERVED8,
109 logStr(SDL_LOG_CATEGORY_RESERVED9,
111 logStr(SDL_LOG_CATEGORY_RESERVED10,
113 logStr(SDL_LOG_CATEGORY_CUSTOM,
116 message.append(
" ?");
124 static SDL_AssertState assertCallback(
const SDL_AssertData *
data,
128 "SDL assert at %s (%s:%d):\n%s",
133 return SDL_ASSERTION_IGNORE;
136 void SDL2Logger::
init()
139 #if SDL_VERSION_ATLEAST(2, 0, 4)
140 SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
143 SDL_LogSetAllPriority(SDL_LOG_PRIORITY_CRITICAL);
147 SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
150 SDL_LogSetOutputFunction(&logCallback,
nullptr);
151 SDL_SetAssertionHandler(&assertCallback,
nullptr);
157 SDL_LogSetAllPriority(
static_cast<SDL_LogPriority
>(level));
159 SDL_LogResetPriorities();
#define reportAlways(...)
bool msg(InputEvent &event)
void setLogLevel(const int level)