2022-01-02 19:28:16 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2022-01-08 18:59:40 -05:00
|
|
|
|
2022-01-02 19:28:16 -05:00
|
|
|
#include <SDL_log.h>
|
|
|
|
#include <stdarg.h>
|
2022-01-08 18:59:40 -05:00
|
|
|
|
2022-01-03 14:48:50 -05:00
|
|
|
#define DEBUG_LOG(...) debug_log (__FILE__, __LINE__, __func__, __VA_ARGS__)
|
2022-01-08 18:59:40 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
debug_log (
|
|
|
|
const char* filename,
|
|
|
|
const int lineno,
|
|
|
|
const char* func,
|
|
|
|
const char* fmt, ...)
|
2022-01-02 19:28:16 -05:00
|
|
|
{
|
|
|
|
va_list ap;
|
2022-01-08 18:59:40 -05:00
|
|
|
char buf[8192];
|
2022-01-02 19:28:16 -05:00
|
|
|
|
2022-01-08 18:59:40 -05:00
|
|
|
SDL_memset (buf, 0, sizeof buf);
|
2022-01-02 19:28:16 -05:00
|
|
|
va_start (ap, fmt);
|
|
|
|
vsnprintf (buf, (sizeof buf) - 1, fmt, ap);
|
|
|
|
va_end (ap);
|
|
|
|
|
2022-01-08 18:59:40 -05:00
|
|
|
SDL_LogMessage (SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG,
|
|
|
|
"%s:%d: %s(): %s", filename, lineno, func, buf);
|
2022-01-02 19:28:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define DEBUG_LOG(...)
|
|
|
|
#endif
|