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