mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-23 02:43:30 +08:00
Improve logging performance and make log priorities thread-safe
Fixes https://github.com/libsdl-org/SDL/issues/9679
This commit is contained in:
parent
f006d61bd1
commit
dc639956ba
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
385
src/SDL_log.c
385
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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user