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
255 return SDL_category_prefixes[
category];
306#if defined(__WIN32__) && !defined(HAVE_STDIO_H) && !defined(__WINRT__)
308static int consoleAttached = 0;
311static HANDLE stderrHandle =
NULL;
318#if defined(__WIN32__) || defined(__WINRT__)
327#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
330 unsigned long charsWritten;
334 if (consoleAttached == 0) {
335 attachResult = AttachConsole(ATTACH_PARENT_PROCESS);
337 attachError = GetLastError();
338 if (attachError == ERROR_INVALID_HANDLE) {
341 consoleAttached = -1;
342 }
else if (attachError == ERROR_GEN_FAILURE) {
343 OutputDebugString(TEXT(
"Could not attach to console of parent process\r\n"));
344 consoleAttached = -1;
345 }
else if (attachError == ERROR_ACCESS_DENIED) {
349 OutputDebugString(TEXT(
"Error attaching console\r\n"));
350 consoleAttached = -1;
357 if (consoleAttached == 1) {
358 stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
360 if (GetConsoleMode(stderrHandle, &consoleMode) == 0) {
374 OutputDebugString(tstr);
376#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
378 if (consoleAttached == 1) {
379 if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten,
NULL)) {
380 OutputDebugString(TEXT(
"Error calling WriteConsole\r\n"));
381 if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
382 OutputDebugString(TEXT(
"Insufficient heap memory to write message\r\n"));
386 }
else if (consoleAttached == 2) {
387 if (!WriteFile(stderrHandle,
output, lstrlenA(
output), &charsWritten,
NULL)) {
388 OutputDebugString(TEXT(
"Error calling WriteFile\r\n"));
396#elif defined(__ANDROID__)
403#elif defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))
406 extern void SDL_NSLog(
const char *
text);
418#elif defined(__PSP__)
421 pFile = fopen (
"SDL_Log.txt",
"a");
#define SDL_small_alloc(type, count, pisstack)
#define SDL_small_free(ptr, isstack)
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 SDL_LogPriority SDL_application_priority
SDL_LogPriority SDL_LogGetPriority(int category)
Get the priority of a particular log category.
static void * SDL_log_userdata
void SDL_LogSetPriority(int category, SDL_LogPriority priority)
Set the priority of a particular log category.
void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
Get the current log output function.
void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
void SDL_LogSetAllPriority(SDL_LogPriority priority)
Set the priority of all log categories.
void SDL_LogResetPriorities(void)
Reset all priorities to default.
#define DEFAULT_ASSERT_PRIORITY
void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_WARN.
void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_INFO.
static SDL_LogLevel * SDL_loglevels
void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_ERROR.
void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_VERBOSE.
static SDL_LogPriority SDL_default_priority
void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
Log a message with the specified category and priority.
static void SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message)
void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_CRITICAL.
static const char * SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES]
static SDL_LogPriority SDL_assert_priority
#define DEFAULT_APPLICATION_PRIORITY
static SDL_LogOutputFunction SDL_log_function
#define DEFAULT_TEST_PRIORITY
void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Log a message with SDL_LOG_PRIORITY_DEBUG.
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 SDL_LogPriority SDL_test_priority
#define SDL_MAX_LOG_MESSAGE
The maximum size of a log message.
SDL_LogPriority
The predefined log priorities.
@ SDL_LOG_PRIORITY_CRITICAL
@ SDL_LOG_PRIORITY_VERBOSE
void(* SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message)
The prototype for the log output function.
@ SDL_LOG_CATEGORY_CUSTOM
@ SDL_LOG_CATEGORY_RESERVED1
@ SDL_LOG_CATEGORY_APPLICATION
@ SDL_LOG_CATEGORY_ASSERT
GLuint GLsizei const GLchar * message
GLuint GLsizei GLsizei * length
#define SDL_arraysize(array)
#define SDL_stack_alloc(type, count)
#define SDL_PRINTF_FORMAT_STRING
#define SDL_stack_free(data)
#define WIN_UTF8ToString(S)
struct SDL_LogLevel * next
static char text[MAX_TEXT_LENGTH]
static Uint32 callback(Uint32 interval, void *param)