Improve logging performance and make log priorities thread-safe

Fixes https://github.com/libsdl-org/SDL/issues/9679
This commit is contained in:
Sam Lantinga 2024-09-16 12:34:42 -07:00
parent f006d61bd1
commit dc639956ba
69 changed files with 289 additions and 349 deletions

View File

@ -120,7 +120,8 @@ typedef enum SDL_LogCategory
*/ */
typedef enum SDL_LogPriority typedef enum SDL_LogPriority
{ {
SDL_LOG_PRIORITY_VERBOSE = 1, SDL_LOG_PRIORITY_INVALID,
SDL_LOG_PRIORITY_VERBOSE,
SDL_LOG_PRIORITY_DEBUG, SDL_LOG_PRIORITY_DEBUG,
SDL_LOG_PRIORITY_INFO, SDL_LOG_PRIORITY_INFO,
SDL_LOG_PRIORITY_WARN, SDL_LOG_PRIORITY_WARN,
@ -135,6 +136,8 @@ typedef enum SDL_LogPriority
* *
* \param priority the SDL_LogPriority to assign. * \param priority the SDL_LogPriority to assign.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_ResetLogPriorities * \sa SDL_ResetLogPriorities
@ -148,14 +151,15 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriorities(SDL_LogPriority priority);
* \param category the category to assign a priority to. * \param category the category to assign a priority to.
* \param priority the SDL_LogPriority to assign. * \param priority the SDL_LogPriority to assign.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetLogPriority * \sa SDL_GetLogPriority
* \sa SDL_ResetLogPriorities * \sa SDL_ResetLogPriorities
* \sa SDL_SetLogPriorities * \sa SDL_SetLogPriorities
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, SDL_LogPriority priority);
SDL_LogPriority priority);
/** /**
* Get the priority of a particular log category. * Get the priority of a particular log category.
@ -163,6 +167,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category,
* \param category the category to query. * \param category the category to query.
* \returns the SDL_LogPriority for the requested category. * \returns the SDL_LogPriority for the requested category.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetLogPriority * \sa SDL_SetLogPriority
@ -174,6 +180,8 @@ extern SDL_DECLSPEC SDL_LogPriority SDLCALL SDL_GetLogPriority(int category);
* *
* This is called by SDL_Quit(). * This is called by SDL_Quit().
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetLogPriorities * \sa SDL_SetLogPriorities
@ -194,6 +202,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void);
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError() * \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
* for more information. * for more information.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetLogPriorities * \sa SDL_SetLogPriorities
@ -208,6 +218,8 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority pr
* \param ... additional parameters matching % tokens in the `fmt` string, if * \param ... additional parameters matching % tokens in the `fmt` string, if
* any. * any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_LogCritical * \sa SDL_LogCritical
@ -229,6 +241,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fm
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -250,6 +264,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -271,6 +287,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_ST
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -292,6 +310,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STR
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -313,6 +333,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STR
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -334,6 +356,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_ST
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -356,6 +380,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any. * if any.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -379,6 +405,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessage(int category,
* \param fmt a printf() style message format string. * \param fmt a printf() style message format string.
* \param ap a variable argument list. * \param ap a variable argument list.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_Log * \sa SDL_Log
@ -397,7 +425,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category,
/** /**
* The prototype for the log output callback function. * The prototype for the log output callback function.
* *
* This function is called by SDL when there is new text to be logged. * This function is called by SDL when there is new text to be logged. A mutex is held so that this function is never called by more than one thread at once.
* *
* \param userdata what was passed as `userdata` to * \param userdata what was passed as `userdata` to
* SDL_SetLogOutputFunction(). * SDL_SetLogOutputFunction().
@ -417,6 +445,8 @@ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_
* \param userdata a pointer filled in with the pointer that is passed to * \param userdata a pointer filled in with the pointer that is passed to
* `callback`. * `callback`.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetLogOutputFunction * \sa SDL_SetLogOutputFunction
@ -429,6 +459,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetLogOutputFunction(SDL_LogOutputFunction
* \param callback an SDL_LogOutputFunction to call instead of the default. * \param callback an SDL_LogOutputFunction to call instead of the default.
* \param userdata a pointer that is passed to `callback`. * \param userdata a pointer that is passed to `callback`.
* *
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetLogOutputFunction * \sa SDL_GetLogOutputFunction

View File

@ -252,21 +252,21 @@ void SDL_InitMainThread(void)
{ {
SDL_InitTLSData(); SDL_InitTLSData();
SDL_InitEnvironment(); SDL_InitEnvironment();
SDL_InitProperties();
SDL_InitHints();
SDL_InitTicks(); SDL_InitTicks();
SDL_InitFilesystem(); SDL_InitFilesystem();
SDL_InitLog(); SDL_InitLog();
SDL_InitProperties();
SDL_GetGlobalProperties(); SDL_GetGlobalProperties();
SDL_InitHints();
} }
static void SDL_QuitMainThread(void) static void SDL_QuitMainThread(void)
{ {
SDL_QuitHints();
SDL_QuitProperties();
SDL_QuitLog(); SDL_QuitLog();
SDL_QuitFilesystem(); SDL_QuitFilesystem();
SDL_QuitTicks(); SDL_QuitTicks();
SDL_QuitHints();
SDL_QuitProperties();
SDL_QuitEnvironment(); SDL_QuitEnvironment();
SDL_QuitTLSData(); SDL_QuitTLSData();
} }

View File

@ -54,14 +54,18 @@ typedef struct SDL_LogLevel
// The default log output function // The default log output function
static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message); static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message);
static void SDL_ResetLogPrefixes(void); static void CleanupLogPriorities(void);
static void CleanupLogPrefixes(void);
static SDL_LogLevel *SDL_loglevels; static SDL_AtomicInt SDL_log_initializing;
static bool SDL_forced_priority = false; static SDL_AtomicInt SDL_log_initialized;
static SDL_LogPriority SDL_forced_priority_level; static SDL_Mutex *SDL_log_lock;
static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; static SDL_Mutex *SDL_log_function_lock;
static void *SDL_log_userdata = NULL; static SDL_LogLevel *SDL_loglevels SDL_GUARDED_BY(SDL_log_lock);
static SDL_Mutex *log_function_mutex = NULL; static SDL_LogPriority SDL_log_priorities[SDL_LOG_CATEGORY_CUSTOM] SDL_GUARDED_BY(SDL_log_lock);
static SDL_LogPriority SDL_log_default_priority SDL_GUARDED_BY(SDL_log_lock);
static SDL_LogOutputFunction SDL_log_function SDL_GUARDED_BY(SDL_log_function_lock) = SDL_LogOutput;
static void *SDL_log_userdata SDL_GUARDED_BY(SDL_log_function_lock) = NULL;
#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA #ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -80,7 +84,8 @@ static const char * const SDL_priority_names[] = {
}; };
SDL_COMPILE_TIME_ASSERT(priority_names, SDL_arraysize(SDL_priority_names) == SDL_LOG_PRIORITY_COUNT); SDL_COMPILE_TIME_ASSERT(priority_names, SDL_arraysize(SDL_priority_names) == SDL_LOG_PRIORITY_COUNT);
static const char *SDL_priority_prefixes[SDL_LOG_PRIORITY_COUNT]; // This is guarded by SDL_log_function_lock because it's the logging function that calls GetLogPriorityPrefix()
static char *SDL_priority_prefixes[SDL_LOG_PRIORITY_COUNT] SDL_GUARDED_BY(SDL_log_function_lock);
// If this list changes, update the documentation for SDL_HINT_LOGGING // If this list changes, update the documentation for SDL_HINT_LOGGING
static const char * const SDL_category_names[] = { static const char * const SDL_category_names[] = {
@ -113,49 +118,107 @@ static int SDL_android_priority[SDL_LOG_PRIORITY_COUNT] = {
}; };
#endif // SDL_PLATFORM_ANDROID #endif // SDL_PLATFORM_ANDROID
static void SDLCALL SDL_LoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
SDL_ResetLogPriorities();
}
void SDL_InitLog(void) void SDL_InitLog(void)
{ {
if (!log_function_mutex) { if (SDL_AtomicGet(&SDL_log_initialized)) {
// if this fails we'll try to continue without it. return;
log_function_mutex = SDL_CreateMutex();
} }
// Do a little tap dance to make sure only one thread initializes logging
if (!SDL_AtomicCompareAndSwap(&SDL_log_initializing, false, true)) {
// Wait for the other thread to complete initialization
while (!SDL_AtomicGet(&SDL_log_initialized)) {
SDL_Delay(1);
}
return;
}
// If these fail we'll continue without them.
SDL_log_lock = SDL_CreateMutex();
SDL_log_function_lock = SDL_CreateMutex();
SDL_AddHintCallback(SDL_HINT_LOGGING, SDL_LoggingChanged, NULL);
SDL_AtomicSet(&SDL_log_initializing, false);
SDL_AtomicSet(&SDL_log_initialized, true);
} }
void SDL_QuitLog(void) void SDL_QuitLog(void)
{ {
SDL_ResetLogPriorities(); SDL_RemoveHintCallback(SDL_HINT_LOGGING, SDL_LoggingChanged, NULL);
SDL_ResetLogPrefixes();
if (log_function_mutex) { CleanupLogPriorities();
SDL_DestroyMutex(log_function_mutex); CleanupLogPrefixes();
log_function_mutex = NULL;
if (SDL_log_lock) {
SDL_DestroyMutex(SDL_log_lock);
SDL_log_lock = NULL;
}
if (SDL_log_function_lock) {
SDL_DestroyMutex(SDL_log_function_lock);
SDL_log_function_lock = NULL;
}
SDL_AtomicSet(&SDL_log_initialized, false);
}
static void SDL_CheckInitLog()
{
if (!SDL_AtomicGet(&SDL_log_initialized) &&
!SDL_AtomicGet(&SDL_log_initializing)) {
SDL_InitLog();
}
}
static void CleanupLogPriorities(void)
{
while (SDL_loglevels) {
SDL_LogLevel *entry = SDL_loglevels;
SDL_loglevels = entry->next;
SDL_free(entry);
} }
} }
void SDL_SetLogPriorities(SDL_LogPriority priority) void SDL_SetLogPriorities(SDL_LogPriority priority)
{ {
SDL_LogLevel *entry; SDL_CheckInitLog();
for (entry = SDL_loglevels; entry; entry = entry->next) { SDL_LockMutex(SDL_log_lock);
entry->priority = priority; {
CleanupLogPriorities();
SDL_log_default_priority = priority;
for (int i = 0; i < SDL_arraysize(SDL_log_priorities); ++i) {
SDL_log_priorities[i] = priority;
} }
}
SDL_forced_priority = true; SDL_UnlockMutex(SDL_log_lock);
SDL_forced_priority_level = priority;
} }
void SDL_SetLogPriority(int category, SDL_LogPriority priority) void SDL_SetLogPriority(int category, SDL_LogPriority priority)
{ {
SDL_LogLevel *entry; SDL_LogLevel *entry;
SDL_CheckInitLog();
SDL_LockMutex(SDL_log_lock);
{
if (category >= 0 && category < SDL_arraysize(SDL_log_priorities)) {
SDL_log_priorities[category] = priority;
} else {
for (entry = SDL_loglevels; entry; entry = entry->next) { for (entry = SDL_loglevels; entry; entry = entry->next) {
if (entry->category == category) { if (entry->category == category) {
entry->priority = priority; entry->priority = priority;
return; break;
} }
} }
// Create a new entry if (!entry) {
entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry));
if (entry) { if (entry) {
entry->category = category; entry->category = category;
@ -164,8 +227,40 @@ void SDL_SetLogPriority(int category, SDL_LogPriority priority)
SDL_loglevels = entry; SDL_loglevels = entry;
} }
} }
}
}
SDL_UnlockMutex(SDL_log_lock);
}
static bool SDL_ParseLogCategory(const char *string, size_t length, int *category) SDL_LogPriority SDL_GetLogPriority(int category)
{
SDL_LogLevel *entry;
SDL_LogPriority priority = SDL_LOG_PRIORITY_INVALID;
SDL_CheckInitLog();
SDL_LockMutex(SDL_log_lock);
{
if (category >= 0 && category < SDL_arraysize(SDL_log_priorities)) {
priority = SDL_log_priorities[category];
} else {
for (entry = SDL_loglevels; entry; entry = entry->next) {
if (entry->category == category) {
priority = entry->priority;
break;
}
}
if (priority == SDL_LOG_PRIORITY_INVALID) {
priority = SDL_log_default_priority;
}
}
}
SDL_UnlockMutex(SDL_log_lock);
return priority;
}
static bool ParseLogCategory(const char *string, size_t length, int *category)
{ {
int i; int i;
@ -188,7 +283,7 @@ static bool SDL_ParseLogCategory(const char *string, size_t length, int *categor
return false; return false;
} }
static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority) static bool ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority)
{ {
int i; int i;
@ -220,13 +315,17 @@ static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPrior
return false; return false;
} }
static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority) static void ParseLogPriorities(const char *hint)
{ {
const char *name, *next; const char *name, *next;
int current_category; int category = DEFAULT_CATEGORY;
SDL_LogPriority priority = SDL_LOG_PRIORITY_COUNT;
if (category == DEFAULT_CATEGORY && SDL_strchr(hint, '=') == NULL) { if (SDL_strchr(hint, '=') == NULL) {
return SDL_ParseLogPriority(hint, SDL_strlen(hint), priority); if (ParseLogPriority(hint, SDL_strlen(hint), &priority)) {
SDL_SetLogPriorities(priority);
}
return;
} }
for (name = hint; name; name = next) { for (name = hint; name; name = next) {
@ -239,8 +338,7 @@ static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_Log
++next; ++next;
} }
if (SDL_ParseLogCategory(name, (sep - name), &current_category)) { if (ParseLogCategory(name, (sep - name), &category)) {
if (current_category == category) {
const char *value = sep + 1; const char *value = sep + 1;
size_t len; size_t len;
if (next) { if (next) {
@ -248,76 +346,78 @@ static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_Log
} else { } else {
len = SDL_strlen(value); len = SDL_strlen(value);
} }
return SDL_ParseLogPriority(value, len, priority); if (ParseLogPriority(value, len, &priority)) {
if (category == DEFAULT_CATEGORY) {
for (int i = 0; i < SDL_arraysize(SDL_log_priorities); ++i) {
if (SDL_log_priorities[i] == SDL_LOG_PRIORITY_INVALID) {
SDL_log_priorities[i] = priority;
}
}
SDL_log_default_priority = priority;
} else {
SDL_SetLogPriority(category, priority);
} }
} }
} }
return false;
} }
static SDL_LogPriority SDL_GetDefaultLogPriority(int category)
{
const char *hint = SDL_GetHint(SDL_HINT_LOGGING);
if (hint) {
SDL_LogPriority priority;
if (SDL_ParseLogCategoryPriority(hint, category, &priority)) {
return priority;
}
if (SDL_ParseLogCategoryPriority(hint, DEFAULT_CATEGORY, &priority)) {
return priority;
}
}
switch (category) {
case SDL_LOG_CATEGORY_APPLICATION:
return SDL_LOG_PRIORITY_INFO;
case SDL_LOG_CATEGORY_ASSERT:
return SDL_LOG_PRIORITY_WARN;
case SDL_LOG_CATEGORY_TEST:
return SDL_LOG_PRIORITY_VERBOSE;
default:
return SDL_LOG_PRIORITY_ERROR;
}
}
SDL_LogPriority SDL_GetLogPriority(int category)
{
SDL_LogLevel *entry;
for (entry = SDL_loglevels; entry; entry = entry->next) {
if (entry->category == category) {
return entry->priority;
}
}
if (SDL_forced_priority) {
return SDL_forced_priority_level;
}
return SDL_GetDefaultLogPriority(category);
} }
void SDL_ResetLogPriorities(void) void SDL_ResetLogPriorities(void)
{ {
SDL_LogLevel *entry; SDL_CheckInitLog();
while (SDL_loglevels) { SDL_LockMutex(SDL_log_lock);
entry = SDL_loglevels; {
SDL_loglevels = entry->next; CleanupLogPriorities();
SDL_free(entry);
} SDL_log_default_priority = SDL_LOG_PRIORITY_INVALID;
SDL_forced_priority = false; for (int i = 0; i < SDL_arraysize(SDL_log_priorities); ++i) {
SDL_log_priorities[i] = SDL_LOG_PRIORITY_INVALID;
} }
static void SDL_ResetLogPrefixes(void) const char *hint = SDL_GetHint(SDL_HINT_LOGGING);
if (hint) {
ParseLogPriorities(hint);
}
if (SDL_log_default_priority == SDL_LOG_PRIORITY_INVALID) {
SDL_log_default_priority = SDL_LOG_PRIORITY_ERROR;
}
for (int i = 0; i < SDL_arraysize(SDL_log_priorities); ++i) {
if (SDL_log_priorities[i] != SDL_LOG_PRIORITY_INVALID) {
continue;
}
switch (i) {
case SDL_LOG_CATEGORY_APPLICATION:
SDL_log_priorities[i] = SDL_LOG_PRIORITY_INFO;
break;
case SDL_LOG_CATEGORY_ASSERT:
SDL_log_priorities[i] = SDL_LOG_PRIORITY_WARN;
break;
case SDL_LOG_CATEGORY_TEST:
SDL_log_priorities[i] = SDL_LOG_PRIORITY_VERBOSE;
break;
default:
SDL_log_priorities[i] = SDL_LOG_PRIORITY_ERROR;
break;
}
}
}
SDL_UnlockMutex(SDL_log_lock);
}
static void CleanupLogPrefixes(void)
{ {
for (int i = 0; i < SDL_arraysize(SDL_priority_prefixes); ++i) { for (int i = 0; i < SDL_arraysize(SDL_priority_prefixes); ++i) {
if (SDL_priority_prefixes[i]) {
SDL_free(SDL_priority_prefixes[i]);
SDL_priority_prefixes[i] = NULL; SDL_priority_prefixes[i] = NULL;
} }
} }
}
static const char *SDL_GetLogPriorityPrefix(SDL_LogPriority priority) static const char *GetLogPriorityPrefix(SDL_LogPriority priority)
{ {
if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_LOG_PRIORITY_COUNT) { if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_LOG_PRIORITY_COUNT) {
return ""; return "";
@ -341,19 +441,30 @@ static const char *SDL_GetLogPriorityPrefix(SDL_LogPriority priority)
SDL_bool SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix) SDL_bool SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix)
{ {
if (priority < SDL_LOG_PRIORITY_VERBOSE || priority >= SDL_LOG_PRIORITY_COUNT) { char *prefix_copy;
if (priority <= SDL_LOG_PRIORITY_INVALID || priority >= SDL_LOG_PRIORITY_COUNT) {
return SDL_InvalidParamError("priority"); return SDL_InvalidParamError("priority");
} }
if (!prefix) { if (!prefix || !*prefix) {
prefix = ""; prefix_copy = SDL_strdup("");
} else { } else {
prefix = SDL_GetPersistentString(prefix); prefix_copy = SDL_strdup(prefix);
if (!prefix) { }
if (!prefix_copy) {
return false; return false;
} }
SDL_LockMutex(SDL_log_function_lock);
{
if (SDL_priority_prefixes[priority]) {
SDL_free(SDL_priority_prefixes[priority]);
} }
SDL_priority_prefixes[priority] = prefix; SDL_priority_prefixes[priority] = prefix_copy;
}
SDL_UnlockMutex(SDL_log_function_lock);
return true; return true;
} }
@ -455,21 +566,11 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
return; return;
} }
// Make sure we don't exceed array bounds
if ((int)priority < 0 || priority >= SDL_LOG_PRIORITY_COUNT) {
return;
}
// See if we want to do anything with this message // See if we want to do anything with this message
if (priority < SDL_GetLogPriority(category)) { if (priority < SDL_GetLogPriority(category)) {
return; return;
} }
if (!log_function_mutex) {
// this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first!
log_function_mutex = SDL_CreateMutex();
}
// Render into stack buffer // Render into stack buffer
va_copy(aq, ap); va_copy(aq, ap);
len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq); len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq);
@ -501,9 +602,11 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
} }
} }
SDL_LockMutex(log_function_mutex); SDL_LockMutex(SDL_log_function_lock);
{
SDL_log_function(SDL_log_userdata, category, priority, message); SDL_log_function(SDL_log_userdata, category, priority, message);
SDL_UnlockMutex(log_function_mutex); }
SDL_UnlockMutex(SDL_log_function_lock);
// Free only if dynamically allocated // Free only if dynamically allocated
if (message != stack_buf) { if (message != stack_buf) {
@ -575,9 +678,9 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
} }
} }
#endif // !defined(SDL_PLATFORM_GDK) #endif // !defined(SDL_PLATFORM_GDK)
length = SDL_strlen(SDL_GetLogPriorityPrefix(priority)) + SDL_strlen(message) + 1 + 1 + 1; length = SDL_strlen(GetLogPriorityPrefix(priority)) + SDL_strlen(message) + 1 + 1 + 1;
output = SDL_small_alloc(char, length, &isstack); output = SDL_small_alloc(char, length, &isstack);
(void)SDL_snprintf(output, length, "%s%s\r\n", SDL_GetLogPriorityPrefix(priority), message); (void)SDL_snprintf(output, length, "%s%s\r\n", GetLogPriorityPrefix(priority), message);
tstr = WIN_UTF8ToString(output); tstr = WIN_UTF8ToString(output);
// Output to debugger // Output to debugger
@ -615,7 +718,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
*/ */
extern void SDL_NSLog(const char *prefix, const char *text); extern void SDL_NSLog(const char *prefix, const char *text);
{ {
SDL_NSLog(SDL_GetLogPriorityPrefix(priority), message); SDL_NSLog(GetLogPriorityPrefix(priority), message);
return; return;
} }
#elif defined(SDL_PLATFORM_PSP) || defined(SDL_PLATFORM_PS2) #elif defined(SDL_PLATFORM_PSP) || defined(SDL_PLATFORM_PS2)
@ -623,7 +726,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
FILE *pFile; FILE *pFile;
pFile = fopen("SDL_Log.txt", "a"); pFile = fopen("SDL_Log.txt", "a");
if (pFile) { if (pFile) {
(void)fprintf(pFile, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); (void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message);
(void)fclose(pFile); (void)fclose(pFile);
} }
} }
@ -632,7 +735,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
FILE *pFile; FILE *pFile;
pFile = fopen("ux0:/data/SDL_Log.txt", "a"); pFile = fopen("ux0:/data/SDL_Log.txt", "a");
if (pFile) { if (pFile) {
(void)fprintf(pFile, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); (void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message);
(void)fclose(pFile); (void)fclose(pFile);
} }
} }
@ -641,7 +744,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
FILE *pFile; FILE *pFile;
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a"); pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
if (pFile) { if (pFile) {
(void)fprintf(pFile, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); (void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message);
(void)fclose(pFile); (void)fclose(pFile);
} }
} }
@ -649,11 +752,13 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
#if defined(HAVE_STDIO_H) && \ #if defined(HAVE_STDIO_H) && \
!(defined(SDL_PLATFORM_APPLE) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) && \ !(defined(SDL_PLATFORM_APPLE) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) && \
!(defined(SDL_PLATFORM_WIN32)) !(defined(SDL_PLATFORM_WIN32))
(void)fprintf(stderr, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); (void)fprintf(stderr, "%s%s\n", GetLogPriorityPrefix(priority), message);
#endif #endif
} }
void SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata) void SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
{
SDL_LockMutex(SDL_log_function_lock);
{ {
if (callback) { if (callback) {
*callback = SDL_log_function; *callback = SDL_log_function;
@ -662,9 +767,15 @@ void SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
*userdata = SDL_log_userdata; *userdata = SDL_log_userdata;
} }
} }
SDL_UnlockMutex(SDL_log_function_lock);
}
void SDL_SetLogOutputFunction(SDL_LogOutputFunction callback, void *userdata) void SDL_SetLogOutputFunction(SDL_LogOutputFunction callback, void *userdata)
{
SDL_LockMutex(SDL_log_function_lock);
{ {
SDL_log_function = callback; SDL_log_function = callback;
SDL_log_userdata = userdata; SDL_log_userdata = userdata;
} }
SDL_UnlockMutex(SDL_log_function_lock);
}

View File

@ -453,9 +453,6 @@ int main(int argc, char *argv[])
} }
state->window_title = "CheckKeys Test"; state->window_title = "CheckKeys Test";
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -56,9 +56,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_SUCCESS; return SDL_APP_SUCCESS;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -712,9 +712,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -122,9 +122,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -63,9 +63,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -40,9 +40,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
return SDL_APP_SUCCESS; return SDL_APP_SUCCESS;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -359,9 +359,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -59,9 +59,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -2005,9 +2005,6 @@ int main(int argc, char *argv[])
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_LINUX_DEADZONES, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_LINUX_DEADZONES, "1");
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Enable input debug logging */ /* Enable input debug logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_INPUT, SDL_LOG_PRIORITY_DEBUG); SDL_SetLogPriority(SDL_LOG_CATEGORY_INPUT, SDL_LOG_PRIORITY_DEBUG);

View File

@ -382,9 +382,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -62,9 +62,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -45,9 +45,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -226,9 +226,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -111,9 +111,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -34,9 +34,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -58,9 +58,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -76,9 +76,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -70,9 +70,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -194,9 +194,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -231,9 +231,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -115,9 +115,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -34,9 +34,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
state->skip_renderer = 1; state->skip_renderer = 1;
if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) {

View File

@ -49,8 +49,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -86,9 +86,6 @@ int main(int argc, char **argv)
state->window_flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE; state->window_flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE;
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -38,9 +38,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;
@ -65,9 +62,6 @@ int main(int argc, char *argv[])
init_subsystems |= SDL_INIT_HAPTIC; init_subsystems |= SDL_INIT_HAPTIC;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
/* Initialize SDL (Note: video is required to start event loop) */ /* Initialize SDL (Note: video is required to start event loop) */

View File

@ -88,9 +88,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -1039,9 +1039,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -295,9 +295,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -29,9 +29,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -45,9 +45,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -45,9 +45,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -120,8 +120,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -499,9 +499,6 @@ int main(int argc, char *argv[])
{ {
int i; int i;
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Log all events, including mouse motion */ /* Log all events, including mouse motion */
SDL_SetHint(SDL_HINT_EVENT_LOGGING, "2"); SDL_SetHint(SDL_HINT_EVENT_LOGGING, "2");

View File

@ -93,9 +93,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -31,9 +31,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -288,9 +288,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -147,9 +147,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -117,9 +117,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -100,9 +100,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -46,9 +46,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed = SDLTest_CommonArg(state, i); int consumed = SDLTest_CommonArg(state, i);

View File

@ -451,9 +451,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -248,9 +248,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -69,9 +69,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -567,9 +567,6 @@ int main(int argc, char *argv[])
runner = SDLTest_CreateTestSuiteRunner(state, testSuites); runner = SDLTest_CreateTestSuiteRunner(state, testSuites);
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -138,9 +138,6 @@ static void loop(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Initialize test framework */ /* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) { if (!state) {

View File

@ -124,9 +124,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) {
SDLTest_CommonQuit(state); SDLTest_CommonQuit(state);
return 1; return 1;

View File

@ -224,9 +224,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -45,9 +45,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
SDL_zero(cvtspec); SDL_zero(cvtspec);
/* Parse commandline */ /* Parse commandline */

View File

@ -48,9 +48,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
name = NULL; name = NULL;
index = -1; index = -1;

View File

@ -73,8 +73,6 @@ int main(int argc, char *argv[])
SDL_AtomicSet(&doterminate, 0); SDL_AtomicSet(&doterminate, 0);
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -111,9 +111,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -266,9 +266,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -68,9 +68,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit(); SDL_Quit();
SDLTest_CommonDestroyState(state); SDLTest_CommonDestroyState(state);

View File

@ -458,9 +458,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -111,9 +111,6 @@ int main(int argc, char *argv[])
int return_code = -1; int return_code = -1;
int i; int i;
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (argc > 1) { if (argc > 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]);
return_code = 1; return_code = 1;

View File

@ -105,9 +105,6 @@ int main(int argc, char *argv[])
int return_code = -1; int return_code = -1;
int i; int i;
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (argc > 1) { if (argc > 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]);
return_code = 1; return_code = 1;

View File

@ -145,9 +145,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit(); SDL_Quit();
SDLTest_CommonDestroyState(state); SDLTest_CommonDestroyState(state);

View File

@ -157,9 +157,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDLTest_CommonQuit(state); SDLTest_CommonQuit(state);
return 1; return 1;

View File

@ -98,9 +98,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -154,9 +154,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
return 1; return 1;

View File

@ -89,9 +89,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -19,9 +19,6 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (argc > 1) { if (argc > 1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]);
return 1; return 1;

View File

@ -1107,9 +1107,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Set Vulkan parameters */ /* Set Vulkan parameters */
state->window_flags |= SDL_WINDOW_VULKAN; state->window_flags |= SDL_WINDOW_VULKAN;
state->skip_renderer = 1; state->skip_renderer = 1;

View File

@ -264,9 +264,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */ /* Parse commandline */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) {
SDLTest_CommonQuit(state); SDLTest_CommonQuit(state);
return 1; return 1;

View File

@ -305,9 +305,6 @@ int main(int argc, char **argv)
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */ /* Parse commandline */
for (i = 1; i < argc;) { for (i = 1; i < argc;) {
int consumed; int consumed;

View File

@ -89,15 +89,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
/* Enable standard application logging */
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Load the SDL library */
if (!SDL_Init(0)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit(); SDL_Quit();
SDLTest_CommonDestroyState(state); SDLTest_CommonDestroyState(state);