From efc390d7e2f0c782fe60c5cf7bc5ffe34b916369 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 2 Jan 2025 17:30:01 -0800 Subject: [PATCH] Don't log SDL errors by default There are many recoverable errors that may happen internally and can be safely ignored if the public API doesn't return an error code. Seeing them causes lots of developer anxiety and they generally aren't helpful. Fixes https://github.com/libsdl-org/SDL/issues/11813 --- src/SDL_error.c | 10 ++++++---- src/test/SDL_test_common.c | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/SDL_error.c b/src/SDL_error.c index a172cdafcc..3c62c8aff4 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -61,10 +61,12 @@ bool SDL_SetErrorV(SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) } } - if (SDL_GetLogPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) { - // If we are in debug mode, print out the error message - SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str); - } +// Enable this if you want to see all errors printed as they occur. +// Note that there are many recoverable errors that may happen internally and +// can be safely ignored if the public API doesn't return an error code. +#if 0 + SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", error->str); +#endif } return false; diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 32441162c8..dd60884e00 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -145,10 +145,6 @@ static int SDLCALL SDLTest_CommonStateParseCommonArguments(void *data, char **ar SDL_SetLogPriorities(SDL_LOG_PRIORITY_VERBOSE); return 2; } - if (SDL_strcasecmp(argv[index], "error") == 0) { - SDL_SetLogPriority(SDL_LOG_CATEGORY_ERROR, SDL_LOG_PRIORITY_VERBOSE); - return 2; - } if (SDL_strcasecmp(argv[index], "system") == 0) { SDL_SetLogPriority(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE); return 2;