diff --git a/include/SDL3/SDL_log.h b/include/SDL3/SDL_log.h index e098af3319..a6618082e2 100644 --- a/include/SDL3/SDL_log.h +++ b/include/SDL3/SDL_log.h @@ -120,7 +120,8 @@ typedef enum SDL_LogCategory */ typedef enum SDL_LogPriority { - SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_INVALID, + SDL_LOG_PRIORITY_VERBOSE, SDL_LOG_PRIORITY_DEBUG, SDL_LOG_PRIORITY_INFO, SDL_LOG_PRIORITY_WARN, @@ -135,6 +136,8 @@ typedef enum SDL_LogPriority * * \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. * * \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 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. * * \sa SDL_GetLogPriority * \sa SDL_ResetLogPriorities * \sa SDL_SetLogPriorities */ -extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, - SDL_LogPriority priority); +extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, SDL_LogPriority priority); /** * 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. * \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. * * \sa SDL_SetLogPriority @@ -174,6 +180,8 @@ extern SDL_DECLSPEC SDL_LogPriority SDLCALL SDL_GetLogPriority(int category); * * 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. * * \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() * for more information. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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 * any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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, * if any. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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 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. * * \sa SDL_Log @@ -397,7 +425,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category, /** * 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 * 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 * `callback`. * + * \threadsafety It is safe to call this function from any thread. + * * \since This function is available since SDL 3.0.0. * * \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 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. * * \sa SDL_GetLogOutputFunction diff --git a/src/SDL.c b/src/SDL.c index 92bed3e92d..58cd19d47d 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -252,21 +252,21 @@ void SDL_InitMainThread(void) { SDL_InitTLSData(); SDL_InitEnvironment(); + SDL_InitProperties(); + SDL_InitHints(); SDL_InitTicks(); SDL_InitFilesystem(); SDL_InitLog(); - SDL_InitProperties(); SDL_GetGlobalProperties(); - SDL_InitHints(); } static void SDL_QuitMainThread(void) { - SDL_QuitHints(); - SDL_QuitProperties(); SDL_QuitLog(); SDL_QuitFilesystem(); SDL_QuitTicks(); + SDL_QuitHints(); + SDL_QuitProperties(); SDL_QuitEnvironment(); SDL_QuitTLSData(); } diff --git a/src/SDL_log.c b/src/SDL_log.c index 9f78a6c6a1..56780e7e0c 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -54,14 +54,18 @@ typedef struct SDL_LogLevel // The default log output function 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 bool SDL_forced_priority = false; -static SDL_LogPriority SDL_forced_priority_level; -static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; -static void *SDL_log_userdata = NULL; -static SDL_Mutex *log_function_mutex = NULL; +static SDL_AtomicInt SDL_log_initializing; +static SDL_AtomicInt SDL_log_initialized; +static SDL_Mutex *SDL_log_lock; +static SDL_Mutex *SDL_log_function_lock; +static SDL_LogLevel *SDL_loglevels SDL_GUARDED_BY(SDL_log_lock); +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 #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); -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 static const char * const SDL_category_names[] = { @@ -113,59 +118,149 @@ static int SDL_android_priority[SDL_LOG_PRIORITY_COUNT] = { }; #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) { - if (!log_function_mutex) { - // if this fails we'll try to continue without it. - log_function_mutex = SDL_CreateMutex(); + if (SDL_AtomicGet(&SDL_log_initialized)) { + return; } + + // 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) { - SDL_ResetLogPriorities(); - SDL_ResetLogPrefixes(); + SDL_RemoveHintCallback(SDL_HINT_LOGGING, SDL_LoggingChanged, NULL); - if (log_function_mutex) { - SDL_DestroyMutex(log_function_mutex); - log_function_mutex = NULL; + CleanupLogPriorities(); + CleanupLogPrefixes(); + + 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) { - SDL_LogLevel *entry; + SDL_CheckInitLog(); - for (entry = SDL_loglevels; entry; entry = entry->next) { - entry->priority = priority; + SDL_LockMutex(SDL_log_lock); + { + 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_forced_priority_level = priority; + SDL_UnlockMutex(SDL_log_lock); } void SDL_SetLogPriority(int category, SDL_LogPriority priority) { SDL_LogLevel *entry; - for (entry = SDL_loglevels; entry; entry = entry->next) { - if (entry->category == category) { - entry->priority = priority; - return; + 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) { + if (entry->category == category) { + entry->priority = priority; + break; + } + } + + if (!entry) { + entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); + if (entry) { + entry->category = category; + entry->priority = priority; + entry->next = SDL_loglevels; + SDL_loglevels = entry; + } + } } } - - // Create a new entry - entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); - if (entry) { - entry->category = category; - entry->priority = priority; - entry->next = SDL_loglevels; - 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; @@ -188,7 +283,7 @@ static bool SDL_ParseLogCategory(const char *string, size_t length, int *categor 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; @@ -220,13 +315,17 @@ static bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPrior return false; } -static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority) +static void ParseLogPriorities(const char *hint) { 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) { - return SDL_ParseLogPriority(hint, SDL_strlen(hint), priority); + if (SDL_strchr(hint, '=') == NULL) { + if (ParseLogPriority(hint, SDL_strlen(hint), &priority)) { + SDL_SetLogPriorities(priority); + } + return; } for (name = hint; name; name = next) { @@ -239,85 +338,86 @@ static bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_Log ++next; } - if (SDL_ParseLogCategory(name, (sep - name), ¤t_category)) { - if (current_category == category) { - const char *value = sep + 1; - size_t len; - if (next) { - len = (next - value - 1); + if (ParseLogCategory(name, (sep - name), &category)) { + const char *value = sep + 1; + size_t len; + if (next) { + len = (next - value - 1); + } else { + len = SDL_strlen(value); + } + 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 { - len = SDL_strlen(value); + SDL_SetLogPriority(category, priority); } - return SDL_ParseLogPriority(value, len, 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) { - SDL_LogLevel *entry; + SDL_CheckInitLog(); - while (SDL_loglevels) { - entry = SDL_loglevels; - SDL_loglevels = entry->next; - SDL_free(entry); + SDL_LockMutex(SDL_log_lock); + { + CleanupLogPriorities(); + + SDL_log_default_priority = SDL_LOG_PRIORITY_INVALID; + for (int i = 0; i < SDL_arraysize(SDL_log_priorities); ++i) { + SDL_log_priorities[i] = SDL_LOG_PRIORITY_INVALID; + } + + 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_forced_priority = false; + SDL_UnlockMutex(SDL_log_lock); } -static void SDL_ResetLogPrefixes(void) +static void CleanupLogPrefixes(void) { for (int i = 0; i < SDL_arraysize(SDL_priority_prefixes); ++i) { - SDL_priority_prefixes[i] = NULL; + if (SDL_priority_prefixes[i]) { + SDL_free(SDL_priority_prefixes[i]); + 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) { return ""; @@ -341,19 +441,30 @@ static const char *SDL_GetLogPriorityPrefix(SDL_LogPriority priority) 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"); } - if (!prefix) { - prefix = ""; + if (!prefix || !*prefix) { + prefix_copy = SDL_strdup(""); } else { - prefix = SDL_GetPersistentString(prefix); - if (!prefix) { - return false; - } + prefix_copy = SDL_strdup(prefix); } - SDL_priority_prefixes[priority] = prefix; + if (!prefix_copy) { + return false; + } + + SDL_LockMutex(SDL_log_function_lock); + { + if (SDL_priority_prefixes[priority]) { + SDL_free(SDL_priority_prefixes[priority]); + } + SDL_priority_prefixes[priority] = prefix_copy; + } + SDL_UnlockMutex(SDL_log_function_lock); + return true; } @@ -455,21 +566,11 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S 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 if (priority < SDL_GetLogPriority(category)) { 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 va_copy(aq, ap); 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_log_function(SDL_log_userdata, category, priority, message); - SDL_UnlockMutex(log_function_mutex); + SDL_LockMutex(SDL_log_function_lock); + { + SDL_log_function(SDL_log_userdata, category, priority, message); + } + SDL_UnlockMutex(SDL_log_function_lock); // Free only if dynamically allocated if (message != stack_buf) { @@ -575,9 +678,9 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority } } #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); - (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); // 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); { - SDL_NSLog(SDL_GetLogPriorityPrefix(priority), message); + SDL_NSLog(GetLogPriorityPrefix(priority), message); return; } #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; pFile = fopen("SDL_Log.txt", "a"); if (pFile) { - (void)fprintf(pFile, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); + (void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message); (void)fclose(pFile); } } @@ -632,7 +735,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority FILE *pFile; pFile = fopen("ux0:/data/SDL_Log.txt", "a"); if (pFile) { - (void)fprintf(pFile, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); + (void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message); (void)fclose(pFile); } } @@ -641,7 +744,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority FILE *pFile; pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a"); if (pFile) { - (void)fprintf(pFile, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); + (void)fprintf(pFile, "%s%s\n", GetLogPriorityPrefix(priority), message); (void)fclose(pFile); } } @@ -649,22 +752,30 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority #if defined(HAVE_STDIO_H) && \ !(defined(SDL_PLATFORM_APPLE) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) && \ !(defined(SDL_PLATFORM_WIN32)) - (void)fprintf(stderr, "%s%s\n", SDL_GetLogPriorityPrefix(priority), message); + (void)fprintf(stderr, "%s%s\n", GetLogPriorityPrefix(priority), message); #endif } void SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata) { - if (callback) { - *callback = SDL_log_function; - } - if (userdata) { - *userdata = SDL_log_userdata; + SDL_LockMutex(SDL_log_function_lock); + { + if (callback) { + *callback = SDL_log_function; + } + if (userdata) { + *userdata = SDL_log_userdata; + } } + SDL_UnlockMutex(SDL_log_function_lock); } void SDL_SetLogOutputFunction(SDL_LogOutputFunction callback, void *userdata) { - SDL_log_function = callback; - SDL_log_userdata = userdata; + SDL_LockMutex(SDL_log_function_lock); + { + SDL_log_function = callback; + SDL_log_userdata = userdata; + } + SDL_UnlockMutex(SDL_log_function_lock); } diff --git a/test/checkkeys.c b/test/checkkeys.c index 937e1043d8..bc9191ac7b 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -453,9 +453,6 @@ int main(int argc, char *argv[]) } state->window_title = "CheckKeys Test"; - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/loopwave.c b/test/loopwave.c index c8d67fc602..be5038d7e4 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -56,9 +56,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) return SDL_APP_SUCCESS; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testatomic.c b/test/testatomic.c index 885f8db359..72ae43c3dd 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -712,9 +712,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index 50e4a3f48d..93aa404f8b 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -122,9 +122,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c index 15b124bfb3..4628ede227 100644 --- a/test/testaudioinfo.c +++ b/test/testaudioinfo.c @@ -63,9 +63,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testaudiorecording.c b/test/testaudiorecording.c index c83c9bc4e0..1189f0fb36 100644 --- a/test/testaudiorecording.c +++ b/test/testaudiorecording.c @@ -40,9 +40,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) return SDL_APP_SUCCESS; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testaudiostreamdynamicresample.c b/test/testaudiostreamdynamicresample.c index ce52ce2ee4..6420e04393 100644 --- a/test/testaudiostreamdynamicresample.c +++ b/test/testaudiostreamdynamicresample.c @@ -359,9 +359,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testcamera.c b/test/testcamera.c index 0ebdaa9c8e..3a02c8162d 100644 --- a/test/testcamera.c +++ b/test/testcamera.c @@ -59,9 +59,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) return SDL_APP_FAILURE; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testcontroller.c b/test/testcontroller.c index ac63690364..fa6a8f007e 100644 --- a/test/testcontroller.c +++ b/test/testcontroller.c @@ -2005,9 +2005,6 @@ int main(int argc, char *argv[]) SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "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 */ SDL_SetLogPriority(SDL_LOG_CATEGORY_INPUT, SDL_LOG_PRIORITY_DEBUG); diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index b362d148f5..6f7f2d0771 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -382,9 +382,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testdialog.c b/test/testdialog.c index 64c1148f7a..7561d7e67e 100644 --- a/test/testdialog.c +++ b/test/testdialog.c @@ -62,9 +62,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c index be3157cd41..88388184d6 100644 --- a/test/testdisplayinfo.c +++ b/test/testdisplayinfo.c @@ -45,9 +45,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testdraw.c b/test/testdraw.c index 2a7d6c36ed..ca9e51d5ed 100644 --- a/test/testdraw.c +++ b/test/testdraw.c @@ -226,9 +226,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 5aa23dc67e..c6a33548bf 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -111,9 +111,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testdropfile.c b/test/testdropfile.c index d778ec7241..c25be58e00 100644 --- a/test/testdropfile.c +++ b/test/testdropfile.c @@ -34,9 +34,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) return SDL_APP_FAILURE; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testerror.c b/test/testerror.c index 043c5855d7..a7c23885c5 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -58,9 +58,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testfile.c b/test/testfile.c index f975f0cf71..e40f286c8c 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -76,9 +76,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testfilesystem.c b/test/testfilesystem.c index 1ae548e5a4..993f608293 100644 --- a/test/testfilesystem.c +++ b/test/testfilesystem.c @@ -70,9 +70,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testgeometry.c b/test/testgeometry.c index 9de8a48aea..3958af1a1e 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -194,9 +194,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testgl.c b/test/testgl.c index 686f4edc43..48bcfd596e 100644 --- a/test/testgl.c +++ b/test/testgl.c @@ -231,9 +231,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testgles.c b/test/testgles.c index c3902630e3..14d4f2e1a8 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -115,9 +115,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testgpu_simple_clear.c b/test/testgpu_simple_clear.c index fe829b1732..61b1a5e01c 100644 --- a/test/testgpu_simple_clear.c +++ b/test/testgpu_simple_clear.c @@ -34,9 +34,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) return SDL_APP_FAILURE; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - state->skip_renderer = 1; if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { diff --git a/test/testhaptic.c b/test/testhaptic.c index 889d4264b3..e55bf29573 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -49,8 +49,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testhittesting.c b/test/testhittesting.c index 098931f339..fcd92a7ed3 100644 --- a/test/testhittesting.c +++ b/test/testhittesting.c @@ -86,9 +86,6 @@ int main(int argc, char **argv) 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 */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testhotplug.c b/test/testhotplug.c index 5dc5665a6b..0972eef0bb 100644 --- a/test/testhotplug.c +++ b/test/testhotplug.c @@ -38,9 +38,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; @@ -65,9 +62,6 @@ int main(int argc, char *argv[]) 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"); /* Initialize SDL (Note: video is required to start event loop) */ diff --git a/test/testiconv.c b/test/testiconv.c index 09f7886518..b11c8fca3e 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -88,9 +88,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testime.c b/test/testime.c index addbfc55f7..59017a879b 100644 --- a/test/testime.c +++ b/test/testime.c @@ -1039,9 +1039,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testintersections.c b/test/testintersections.c index 6223aafa6a..b86bb5a3ba 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -295,9 +295,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testkeys.c b/test/testkeys.c index ede13c8877..c098eca56d 100644 --- a/test/testkeys.c +++ b/test/testkeys.c @@ -29,9 +29,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testloadso.c b/test/testloadso.c index 3a5a5280cd..2a6f0e532a 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -45,9 +45,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testlocale.c b/test/testlocale.c index d0196d2e56..4a34ecadf3 100644 --- a/test/testlocale.c +++ b/test/testlocale.c @@ -45,9 +45,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testlock.c b/test/testlock.c index bee8781f02..0cc155b70b 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -120,8 +120,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testmanymouse.c b/test/testmanymouse.c index cdd15f52c0..6890ca3589 100644 --- a/test/testmanymouse.c +++ b/test/testmanymouse.c @@ -499,9 +499,6 @@ int main(int argc, char *argv[]) { int i; - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Log all events, including mouse motion */ SDL_SetHint(SDL_HINT_EVENT_LOGGING, "2"); diff --git a/test/testmessage.c b/test/testmessage.c index 138a24dcab..c17f229a69 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -93,9 +93,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testmodal.c b/test/testmodal.c index 4fa9c1abd1..1d4650cfab 100644 --- a/test/testmodal.c +++ b/test/testmodal.c @@ -31,9 +31,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testmouse.c b/test/testmouse.c index 5a08a97dc3..8defd5b05c 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -288,9 +288,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index b978d00acf..9c898a43ba 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -147,9 +147,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testnative.c b/test/testnative.c index 8e8db6a4cf..3899a6434d 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -117,9 +117,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testoffscreen.c b/test/testoffscreen.c index d4b4b875a8..eecd82aa79 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -100,9 +100,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testpen.c b/test/testpen.c index bc7dc1c9e4..0be0092f6f 100644 --- a/test/testpen.c +++ b/test/testpen.c @@ -46,9 +46,6 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) return SDL_APP_FAILURE; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed = SDLTest_CommonArg(state, i); diff --git a/test/testplatform.c b/test/testplatform.c index 09a3064e34..8fcd779c65 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -451,9 +451,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testpopup.c b/test/testpopup.c index ecb04128f1..683d7f23e6 100644 --- a/test/testpopup.c +++ b/test/testpopup.c @@ -248,9 +248,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testpower.c b/test/testpower.c index 190e3ae889..88e3221878 100644 --- a/test/testpower.c +++ b/test/testpower.c @@ -69,9 +69,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testprocess.c b/test/testprocess.c index 7fb53eeabb..c345f710db 100644 --- a/test/testprocess.c +++ b/test/testprocess.c @@ -567,9 +567,6 @@ int main(int argc, char *argv[]) runner = SDLTest_CreateTestSuiteRunner(state, testSuites); - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testrelative.c b/test/testrelative.c index 039ddf4c14..a26a0859e9 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -138,9 +138,6 @@ static void loop(void) int main(int argc, char *argv[]) { - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 0caaea74c3..ead35a2e6c 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -124,9 +124,6 @@ int main(int argc, char *argv[]) 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)) { SDLTest_CommonQuit(state); return 1; diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 74b742c10f..082cab5c7e 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -224,9 +224,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - for (i = 1; i < argc;) { int consumed; diff --git a/test/testresample.c b/test/testresample.c index 0d1c5dcf83..122b12dd52 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -45,9 +45,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - SDL_zero(cvtspec); /* Parse commandline */ diff --git a/test/testrumble.c b/test/testrumble.c index e46c73ca8c..0b6d2c44cb 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -48,9 +48,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - name = NULL; index = -1; diff --git a/test/testrwlock.c b/test/testrwlock.c index 762693ab04..f047d85519 100644 --- a/test/testrwlock.c +++ b/test/testrwlock.c @@ -73,8 +73,6 @@ int main(int argc, char *argv[]) SDL_AtomicSet(&doterminate, 0); - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testscale.c b/test/testscale.c index f0e535baae..76890401f2 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -111,9 +111,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testsem.c b/test/testsem.c index 30485dc8ac..b07a096716 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -266,9 +266,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testsensor.c b/test/testsensor.c index 57566f4f8a..89aaaa6188 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -68,9 +68,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { SDL_Quit(); SDLTest_CommonDestroyState(state); diff --git a/test/testshader.c b/test/testshader.c index 71df993bb8..057376c720 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -458,9 +458,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 16a41a4c4f..3caeb35e5c 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -111,9 +111,6 @@ int main(int argc, char *argv[]) int return_code = -1; int i; - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - if (argc > 1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]); return_code = 1; diff --git a/test/testspritesurface.c b/test/testspritesurface.c index 4abd7efd70..42ca8479ab 100644 --- a/test/testspritesurface.c +++ b/test/testspritesurface.c @@ -105,9 +105,6 @@ int main(int argc, char *argv[]) int return_code = -1; int i; - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - if (argc > 1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s\n", argv[0]); return_code = 1; diff --git a/test/teststreaming.c b/test/teststreaming.c index 8cc7b4ecfc..3a5e506cf5 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -145,9 +145,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { SDL_Quit(); SDLTest_CommonDestroyState(state); diff --git a/test/testsurround.c b/test/testsurround.c index 876ebd0d0a..3d9bf7de17 100644 --- a/test/testsurround.c +++ b/test/testsurround.c @@ -157,9 +157,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { SDLTest_CommonQuit(state); return 1; diff --git a/test/testthread.c b/test/testthread.c index a18f8fcfd0..b9c698ad3d 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -98,9 +98,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testtime.c b/test/testtime.c index 14e8a57b22..c1b419e152 100644 --- a/test/testtime.c +++ b/test/testtime.c @@ -154,9 +154,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { return 1; diff --git a/test/testtimer.c b/test/testtimer.c index 82baf98f34..8c18ac0638 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -89,9 +89,6 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/testver.c b/test/testver.c index b417e088f3..e259fc5f2a 100644 --- a/test/testver.c +++ b/test/testver.c @@ -19,9 +19,6 @@ int main(int argc, char *argv[]) { - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - if (argc > 1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "USAGE: %s", argv[0]); return 1; diff --git a/test/testvulkan.c b/test/testvulkan.c index 3f0afb59b4..41e21544b8 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -1107,9 +1107,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Set Vulkan parameters */ state->window_flags |= SDL_WINDOW_VULKAN; state->skip_renderer = 1; diff --git a/test/testwm.c b/test/testwm.c index e6fa65cabb..b48b898a1f 100644 --- a/test/testwm.c +++ b/test/testwm.c @@ -264,9 +264,7 @@ int main(int argc, char *argv[]) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - + /* Parse commandline */ if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { SDLTest_CommonQuit(state); return 1; diff --git a/test/testyuv.c b/test/testyuv.c index 30adeb34e2..26fb3f30a7 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -305,9 +305,6 @@ int main(int argc, char **argv) return 1; } - /* Enable standard application logging */ - SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Parse commandline */ for (i = 1; i < argc;) { int consumed; diff --git a/test/torturethread.c b/test/torturethread.c index deea79cea2..9182149965 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -89,15 +89,6 @@ int main(int argc, char *argv[]) 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)) { SDL_Quit(); SDLTest_CommonDestroyState(state);