Pārlūkot izejas kodu

hints: Renamed SDL_HINT_LOG_BACKENDS to SDL_DEBUG_LOGGING.

This still logs backend choices, but we might use it for other things. For
example, what Android device is being used, or all the devices we enumerated,
etc.

Ideally this eventually logs all the stuff we often have to ask followup
questions about.
Ryan C. Gordon 1 mēnesi atpakaļ
vecāks
revīzija
07ef532681

+ 12 - 9
include/SDL3/SDL_hints.h

@@ -4396,26 +4396,29 @@ extern "C" {
 #define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS"
 
 /**
- * A variable controlling whether SDL backend information is logged.
+ * A variable controlling whether SDL logs some debug information.
  *
  * The variable can be set to the following values:
  *
- * - "0": Subsystem information will not be logged. (default)
- * - "1": Subsystem information will be logged.
+ * - "0": SDL debug information will not be logged. (default)
+ * - "1": SDL debug information will be logged.
  *
  * This is generally meant to be used as an environment variable to let
- * end-users report what subsystems were chosen on their system, to aid in
- * debugging. Logged information is sent through SDL_Log(), which means by
- * default they appear on stdout on most platforms or maybe
- * OutputDebugString() on Windows, and can be funneled by the app with
- * SDL_SetLogOutputFunction(), etc.
+ * end-users report what subsystems were chosen on their system, perhaps what
+ * sort of hardware they are running on, etc, to aid in debugging. Logged
+ * information is sent through SDL_Log(), which means by default they appear
+ * on stdout on most platforms, or maybe OutputDebugString() on Windows, and
+ * can be funneled by the app with SDL_SetLogOutputFunction(), etc.
+ *
+ * The specific output might change between SDL versions; more information
+ * might be deemed useful in the future.
  *
  * This hint can be set anytime, but the specific logs are generated during
  * subsystem init.
  *
  * \since This hint is available since SDL 3.4.0.
  */
-#define SDL_HINT_LOG_BACKENDS "SDL_LOG_BACKENDS"
+#define SDL_HINT_DEBUG_LOGGING "SDL_DEBUG_LOGGING"
 
 /**
  * An enumeration of hint priorities.

+ 5 - 4
src/SDL_utils.c

@@ -553,11 +553,12 @@ char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_nam
     return name;
 }
 
-void SDL_LogBackend(const char *subsystem, const char *backend)
+#define SDL_DEBUG_LOG_INTRO "SDL_DEBUG: "
+
+void SDL_DebugLogBackend(const char *subsystem, const char *backend)
 {
-    if (SDL_GetHintBoolean(SDL_HINT_LOG_BACKENDS, false)) {
-        SDL_Log("SDL_BACKEND: %s -> '%s'", subsystem, backend);
+    if (SDL_GetHintBoolean(SDL_HINT_DEBUG_LOGGING, false)) {
+        SDL_Log(SDL_DEBUG_LOG_INTRO "chose %s backend '%s'", subsystem, backend);
     }
 }
 
-

+ 1 - 1
src/SDL_utils_c.h

@@ -76,6 +76,6 @@ extern const char *SDL_GetPersistentString(const char *string);
 extern char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name, const char *default_name);
 
 // Log what backend a subsystem chose, if a hint was set to do so. Useful for debugging.
-extern void SDL_LogBackend(const char *subsystem, const char *backend);
+extern void SDL_DebugLogBackend(const char *subsystem, const char *backend);
 
 #endif // SDL_utils_h_

+ 1 - 1
src/audio/SDL_audio.c

@@ -1007,7 +1007,7 @@ bool SDL_InitAudio(const char *driver_name)
     }
 
     if (initialized) {
-        SDL_LogBackend("audio", current_audio.name);
+        SDL_DebugLogBackend("audio", current_audio.name);
     } else {
         // specific drivers will set the error message if they fail, but otherwise we do it here.
         if (!tried_to_init) {

+ 1 - 1
src/camera/SDL_camera.c

@@ -1525,7 +1525,7 @@ bool SDL_CameraInit(const char *driver_name)
     }
 
     if (initialized) {
-        SDL_LogBackend("camera", camera_driver.name);
+        SDL_DebugLogBackend("camera", camera_driver.name);
     } else {
         // specific drivers will set the error message if they fail, but otherwise we do it here.
         if (!tried_to_init) {

+ 1 - 1
src/gpu/SDL_gpu.c

@@ -711,7 +711,7 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
 
     selectedBackend = SDL_GPUSelectBackend(props);
     if (selectedBackend != NULL) {
-        SDL_LogBackend("gpu", selectedBackend->name);
+        SDL_DebugLogBackend("gpu", selectedBackend->name);
         debug_mode = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN, true);
         preferLowPower = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN, false);
 

+ 2 - 2
src/io/io_uring/SDL_asyncio_liburing.c

@@ -512,12 +512,12 @@ static void MaybeInitializeLibUring(void)
 {
     if (SDL_ShouldInit(&liburing_init)) {
         if (LoadLibUring()) {
-            SDL_LogBackend("asyncio", "liburing");
+            SDL_DebugLogBackend("asyncio", "liburing");
             CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_liburing;
             QuitAsyncIO = SDL_SYS_QuitAsyncIO_liburing;
             AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_liburing;
         } else {  // can't use liburing? Use the "generic" threadpool implementation instead.
-            SDL_LogBackend("asyncio", "generic");
+            SDL_DebugLogBackend("asyncio", "generic");
             CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_Generic;
             QuitAsyncIO = SDL_SYS_QuitAsyncIO_Generic;
             AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_Generic;

+ 2 - 2
src/io/windows/SDL_asyncio_windows_ioring.c

@@ -511,12 +511,12 @@ static void MaybeInitializeWinIoRing(void)
 {
     if (SDL_ShouldInit(&ioring_init)) {
         if (LoadWinIoRing()) {
-            SDL_LogBackend("asyncio", "ioring");
+            SDL_DebugLogBackend("asyncio", "ioring");
             CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_ioring;
             QuitAsyncIO = SDL_SYS_QuitAsyncIO_ioring;
             AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_ioring;
         } else {  // can't use ioring? Use the "generic" threadpool implementation instead.
-            SDL_LogBackend("asyncio", "generic");
+            SDL_DebugLogBackend("asyncio", "generic");
             CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_Generic;
             QuitAsyncIO = SDL_SYS_QuitAsyncIO_Generic;
             AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_Generic;

+ 1 - 1
src/render/SDL_render.c

@@ -1064,7 +1064,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
         }
 
         if (rc) {
-            SDL_LogBackend("render", renderer->name);
+            SDL_DebugLogBackend("render", renderer->name);
         } else {
             if (driver_name) {
                 SDL_SetError("%s not available", driver_name);

+ 2 - 2
src/storage/SDL_storage.c

@@ -119,7 +119,7 @@ SDL_Storage *SDL_OpenTitleStorage(const char *override, SDL_PropertiesID props)
         }
     }
     if (storage) {
-        SDL_LogBackend("title_storage", titlebootstrap[i]->name);
+        SDL_DebugLogBackend("title_storage", titlebootstrap[i]->name);
     } else {
         if (driver_name) {
             SDL_SetError("%s not available", driver_name);
@@ -163,7 +163,7 @@ SDL_Storage *SDL_OpenUserStorage(const char *org, const char *app, SDL_Propertie
         }
     }
     if (storage) {
-        SDL_LogBackend("user_storage", userbootstrap[i]->name);
+        SDL_DebugLogBackend("user_storage", userbootstrap[i]->name);
     } else {
         if (driver_name) {
             SDL_SetError("%s not available", driver_name);

+ 1 - 1
src/video/SDL_video.c

@@ -680,7 +680,7 @@ bool SDL_VideoInit(const char *driver_name)
         }
     }
     if (video) {
-        SDL_LogBackend("video", bootstrap[i]->name);
+        SDL_DebugLogBackend("video", bootstrap[i]->name);
     } else {
         if (driver_name) {
             SDL_SetError("%s not available", driver_name);