23 #if defined(__WIN32__) || defined(__WINRT__)
36 #if defined(__ANDROID__)
37 #include <android/log.h>
40 #define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL
41 #define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN
42 #define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO
43 #define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE
101 for (entry = SDL_loglevels; entry; entry = entry->
next) {
114 for (entry = SDL_loglevels; entry; entry = entry->
next) {
127 SDL_loglevels = entry;
136 for (entry = SDL_loglevels; entry; entry = entry->
next) {
158 while (SDL_loglevels) {
160 SDL_loglevels = entry->
next;
255 return SDL_category_prefixes[
category];
294 if ((len > 0) && (message[len-1] ==
'\n')) {
295 message[--
len] =
'\0';
296 if ((len > 0) && (message[len-1] ==
'\r')) {
297 message[--
len] =
'\0';
305 #if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__)
307 static int consoleAttached = 0;
310 static HANDLE stderrHandle =
NULL;
317 #if defined(__WIN32__) || defined(__WINRT__)
325 #if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
328 unsigned long charsWritten;
332 if (consoleAttached == 0) {
333 attachResult = AttachConsole(ATTACH_PARENT_PROCESS);
335 attachError = GetLastError();
336 if (attachError == ERROR_INVALID_HANDLE) {
339 consoleAttached = -1;
340 }
else if (attachError == ERROR_GEN_FAILURE) {
341 OutputDebugString(TEXT(
"Could not attach to console of parent process\r\n"));
342 consoleAttached = -1;
343 }
else if (attachError == ERROR_ACCESS_DENIED) {
347 OutputDebugString(TEXT(
"Error attaching console\r\n"));
348 consoleAttached = -1;
355 if (consoleAttached == 1) {
356 stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
358 if (GetConsoleMode(stderrHandle, &consoleMode) == 0) {
372 OutputDebugString(tstr);
374 #if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
376 if (consoleAttached == 1) {
377 if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten,
NULL)) {
378 OutputDebugString(TEXT(
"Error calling WriteConsole\r\n"));
379 if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
380 OutputDebugString(TEXT(
"Insufficient heap memory to write message\r\n"));
384 }
else if (consoleAttached == 2) {
385 if (!WriteFile(stderrHandle, output, lstrlenA(output), &charsWritten,
NULL)) {
386 OutputDebugString(TEXT(
"Error calling WriteFile\r\n"));
394 #elif defined(__ANDROID__)
399 __android_log_write(SDL_android_priority[priority], tag, message);
401 #elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
404 extern void SDL_NSLog(
const char *
text);
416 #elif defined(__PSP__)
419 pFile = fopen (
"SDL_Log.txt",
"a");