diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h index 25e41ed75c..c65b09d269 100644 --- a/include/SDL3/SDL_hints.h +++ b/include/SDL3/SDL_hints.h @@ -2410,6 +2410,10 @@ extern "C" { * * `app=info,assert=warn,test=verbose,*=error` * + * If the `DEBUG_INVOCATION` environment variable is set to "1", the default log levels are equivalent to: + * + * `assert=warn,test=verbose,*=debug` + * * This hint can be set anytime. * * \since This hint is available since SDL 3.2.0. diff --git a/src/SDL_log.c b/src/SDL_log.c index da55dcf1c1..39bb5ba1e2 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -375,6 +375,9 @@ void SDL_ResetLogPriorities(void) SDL_LockMutex(SDL_log_lock); { + const char *env = SDL_getenv("DEBUG_INVOCATION"); + bool debug = (env && *env && *env != '0'); + CleanupLogPriorities(); SDL_log_default_priority = SDL_LOG_PRIORITY_INVALID; @@ -397,7 +400,11 @@ void SDL_ResetLogPriorities(void) switch (i) { case SDL_LOG_CATEGORY_APPLICATION: - SDL_log_priorities[i] = SDL_LOG_PRIORITY_INFO; + if (debug) { + SDL_log_priorities[i] = SDL_LOG_PRIORITY_DEBUG; + } else { + SDL_log_priorities[i] = SDL_LOG_PRIORITY_INFO; + } break; case SDL_LOG_CATEGORY_ASSERT: SDL_log_priorities[i] = SDL_LOG_PRIORITY_WARN; @@ -406,7 +413,11 @@ void SDL_ResetLogPriorities(void) SDL_log_priorities[i] = SDL_LOG_PRIORITY_VERBOSE; break; default: - SDL_log_priorities[i] = SDL_LOG_PRIORITY_ERROR; + if (debug) { + SDL_log_priorities[i] = SDL_LOG_PRIORITY_DEBUG; + } else { + SDL_log_priorities[i] = SDL_LOG_PRIORITY_ERROR; + } break; } }