31 #if defined(__WIN32__)
33 #elif defined(__ANDROID__)
34 #include <android/log.h>
37 #define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL
38 #define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN
39 #define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO
40 #define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE
103 for (entry = SDL_loglevels; entry; entry = entry->next) {
104 entry->priority = priority;
116 for (entry = SDL_loglevels; entry; entry = entry->next) {
117 if (entry->category == category) {
118 entry->priority = priority;
126 entry->category = category;
127 entry->priority = priority;
129 SDL_loglevels = entry;
138 for (entry = SDL_loglevels; entry; entry = entry->next) {
139 if (entry->category == category) {
140 return entry->priority;
160 while (SDL_loglevels) {
162 SDL_loglevels = entry->next;
254 GetCategoryPrefix(
int category)
257 return SDL_category_prefixes[category];
296 if ((len > 0) && (message[len-1] ==
'\n')) {
297 message[--
len] =
'\0';
298 if ((len > 0) && (message[len-1] ==
'\r')) {
299 message[--
len] =
'\0';
307 #if defined(__WIN32__)
309 static int consoleAttached = 0;
319 #if defined(__WIN32__)
328 unsigned long charsWritten;
331 if (consoleAttached == 0) {
332 attachResult = AttachConsole(ATTACH_PARENT_PROCESS);
334 attachError = GetLastError();
335 if (attachError == ERROR_INVALID_HANDLE) {
336 OutputDebugString(TEXT(
"Parent process has no console\r\n"));
337 consoleAttached = -1;
338 }
else if (attachError == ERROR_GEN_FAILURE) {
339 OutputDebugString(TEXT(
"Could not attach to console of parent process\r\n"));
340 consoleAttached = -1;
341 }
else if (attachError == ERROR_ACCESS_DENIED) {
345 OutputDebugString(TEXT(
"Error attaching console\r\n"));
346 consoleAttached = -1;
353 if (consoleAttached == 1) {
354 stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
364 OutputDebugString(tstr);
367 if (consoleAttached == 1) {
368 if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten,
NULL)) {
369 OutputDebugString(TEXT(
"Error calling WriteConsole\r\n"));
371 if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) {
372 OutputDebugString(TEXT(
"Insufficient heap memory to write message\r\n"));
379 #elif defined(__ANDROID__)
384 __android_log_write(SDL_android_priority[priority], tag, message);
386 #elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
389 extern void SDL_NSLog(
const char *text);
401 #elif defined(__PSP__)
404 pFile = fopen (
"SDL_Log.txt",
"a");
#define DEFAULT_APPLICATION_PRIORITY
#define SDL_MAX_LOG_MESSAGE
The maximum size of a log message.
#define WIN_UTF8ToString(S)
static SDL_LogPriority SDL_test_priority
static SDL_LogLevel * SDL_loglevels
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt,...)
#define SDL_stack_free(data)
#define DEFAULT_ASSERT_PRIORITY
DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority)
Set the priority of all log categories.
static const char * SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES]
DECLSPEC void SDLCALL SDL_free(void *mem)
DECLSPEC void SDLCALL SDL_LogResetPriorities(void)
Reset all priorities to default.
DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_CRITICAL.
DECLSPEC void SDLCALL SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
Log a message with the specified category and priority.
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC
static SDL_LogOutputFunction SDL_log_function
static SDL_LogPriority SDL_assert_priority
DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_DEBUG.
static SDL_LogPriority SDL_default_priority
void(* SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message)
The prototype for the log output function.
DECLSPEC void SDLCALL SDL_LogSetPriority(int category, SDL_LogPriority priority)
Set the priority of a particular log category.
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
SDL_LogPriority
The predefined log priorities.
DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
This function allows you to replace the default log output function with one of your own...
DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category)
Get the priority of a particular log category.
static void * SDL_log_userdata
DECLSPEC size_t SDLCALL SDL_strlen(const char *str)
#define SDL_arraysize(array)
DECLSPEC void SDLCALL SDL_Log(const char *fmt,...)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_VERBOSE.
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_ERROR.
DECLSPEC void SDLCALL SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt,...)
Log a message with the specified category and priority.
DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_WARN.
DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
Get the current log output function.
#define SDL_stack_alloc(type, count)
static SDL_LogPriority SDL_application_priority
struct SDL_LogLevel SDL_LogLevel
#define DEFAULT_TEST_PRIORITY
DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_INFO.
static void SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message)
DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
typedef BOOL(WINAPI *PFNWGLSETSTEREOEMITTERSTATE3DLPROC)(HDC hDC