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");
#define DEFAULT_APPLICATION_PRIORITY
void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_DEBUG.
#define SDL_MAX_LOG_MESSAGE
The maximum size of a log message.
#define WIN_UTF8ToString(S)
static SDL_LogPriority SDL_test_priority
void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_CRITICAL.
static SDL_LogLevel * SDL_loglevels
GLuint GLsizei const GLchar * message
#define DEFAULT_ASSERT_PRIORITY
static const char * SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES]
void SDL_LogSetAllPriority(SDL_LogPriority priority)
Set the priority of all log categories.
void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_WARN.
void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_VERBOSE.
void SDL_LogResetPriorities(void)
Reset all priorities to default.
static SDL_LogOutputFunction SDL_log_function
void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
static SDL_LogPriority SDL_assert_priority
static SDL_LogPriority SDL_default_priority
#define SDL_stack_alloc(type, count)
struct SDL_LogLevel * next
void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
This function allows you to replace the default log output function with one of your own...
static Uint32 callback(Uint32 interval, void *param)
void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
Log a message with the specified category and priority.
SDL_LogPriority SDL_LogGetPriority(int category)
Get the priority of a particular log category.
SDL_LogPriority
The predefined log priorities.
void(* SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message)
The prototype for the log output function.
static void * SDL_log_userdata
void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
Get the current log output function.
static char text[MAX_TEXT_LENGTH]
void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_ERROR.
#define SDL_arraysize(array)
void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_INFO.
static SDL_LogPriority SDL_application_priority
#define SDL_stack_free(data)
#define SDL_PRINTF_FORMAT_STRING
void SDL_LogSetPriority(int category, SDL_LogPriority priority)
Set the priority of a particular log category.
GLuint GLsizei GLsizei * length
#define DEFAULT_TEST_PRIORITY
void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with the specified category and priority.
static void SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message)