Skip to content

Commit 07ef532

Browse files
committed
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.
1 parent af1c05f commit 07ef532

File tree

11 files changed

+29
-25
lines changed

11 files changed

+29
-25
lines changed

include/SDL3/SDL_hints.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,26 +4396,29 @@ extern "C" {
43964396
#define SDL_HINT_PEN_TOUCH_EVENTS "SDL_PEN_TOUCH_EVENTS"
43974397

43984398
/**
4399-
* A variable controlling whether SDL backend information is logged.
4399+
* A variable controlling whether SDL logs some debug information.
44004400
*
44014401
* The variable can be set to the following values:
44024402
*
4403-
* - "0": Subsystem information will not be logged. (default)
4404-
* - "1": Subsystem information will be logged.
4403+
* - "0": SDL debug information will not be logged. (default)
4404+
* - "1": SDL debug information will be logged.
44054405
*
44064406
* This is generally meant to be used as an environment variable to let
4407-
* end-users report what subsystems were chosen on their system, to aid in
4408-
* debugging. Logged information is sent through SDL_Log(), which means by
4409-
* default they appear on stdout on most platforms or maybe
4410-
* OutputDebugString() on Windows, and can be funneled by the app with
4411-
* SDL_SetLogOutputFunction(), etc.
4407+
* end-users report what subsystems were chosen on their system, perhaps what
4408+
* sort of hardware they are running on, etc, to aid in debugging. Logged
4409+
* information is sent through SDL_Log(), which means by default they appear
4410+
* on stdout on most platforms, or maybe OutputDebugString() on Windows, and
4411+
* can be funneled by the app with SDL_SetLogOutputFunction(), etc.
4412+
*
4413+
* The specific output might change between SDL versions; more information
4414+
* might be deemed useful in the future.
44124415
*
44134416
* This hint can be set anytime, but the specific logs are generated during
44144417
* subsystem init.
44154418
*
44164419
* \since This hint is available since SDL 3.4.0.
44174420
*/
4418-
#define SDL_HINT_LOG_BACKENDS "SDL_LOG_BACKENDS"
4421+
#define SDL_HINT_DEBUG_LOGGING "SDL_DEBUG_LOGGING"
44194422

44204423
/**
44214424
* An enumeration of hint priorities.

src/SDL_utils.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,12 @@ char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_nam
553553
return name;
554554
}
555555

556-
void SDL_LogBackend(const char *subsystem, const char *backend)
556+
#define SDL_DEBUG_LOG_INTRO "SDL_DEBUG: "
557+
558+
void SDL_DebugLogBackend(const char *subsystem, const char *backend)
557559
{
558-
if (SDL_GetHintBoolean(SDL_HINT_LOG_BACKENDS, false)) {
559-
SDL_Log("SDL_BACKEND: %s -> '%s'", subsystem, backend);
560+
if (SDL_GetHintBoolean(SDL_HINT_DEBUG_LOGGING, false)) {
561+
SDL_Log(SDL_DEBUG_LOG_INTRO "chose %s backend '%s'", subsystem, backend);
560562
}
561563
}
562564

563-

src/SDL_utils_c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ extern const char *SDL_GetPersistentString(const char *string);
7676
extern char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name, const char *default_name);
7777

7878
// Log what backend a subsystem chose, if a hint was set to do so. Useful for debugging.
79-
extern void SDL_LogBackend(const char *subsystem, const char *backend);
79+
extern void SDL_DebugLogBackend(const char *subsystem, const char *backend);
8080

8181
#endif // SDL_utils_h_

src/audio/SDL_audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ bool SDL_InitAudio(const char *driver_name)
10071007
}
10081008

10091009
if (initialized) {
1010-
SDL_LogBackend("audio", current_audio.name);
1010+
SDL_DebugLogBackend("audio", current_audio.name);
10111011
} else {
10121012
// specific drivers will set the error message if they fail, but otherwise we do it here.
10131013
if (!tried_to_init) {

src/camera/SDL_camera.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ bool SDL_CameraInit(const char *driver_name)
15251525
}
15261526

15271527
if (initialized) {
1528-
SDL_LogBackend("camera", camera_driver.name);
1528+
SDL_DebugLogBackend("camera", camera_driver.name);
15291529
} else {
15301530
// specific drivers will set the error message if they fail, but otherwise we do it here.
15311531
if (!tried_to_init) {

src/gpu/SDL_gpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
711711

712712
selectedBackend = SDL_GPUSelectBackend(props);
713713
if (selectedBackend != NULL) {
714-
SDL_LogBackend("gpu", selectedBackend->name);
714+
SDL_DebugLogBackend("gpu", selectedBackend->name);
715715
debug_mode = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_DEBUGMODE_BOOLEAN, true);
716716
preferLowPower = SDL_GetBooleanProperty(props, SDL_PROP_GPU_DEVICE_CREATE_PREFERLOWPOWER_BOOLEAN, false);
717717

src/io/io_uring/SDL_asyncio_liburing.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,12 @@ static void MaybeInitializeLibUring(void)
512512
{
513513
if (SDL_ShouldInit(&liburing_init)) {
514514
if (LoadLibUring()) {
515-
SDL_LogBackend("asyncio", "liburing");
515+
SDL_DebugLogBackend("asyncio", "liburing");
516516
CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_liburing;
517517
QuitAsyncIO = SDL_SYS_QuitAsyncIO_liburing;
518518
AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_liburing;
519519
} else { // can't use liburing? Use the "generic" threadpool implementation instead.
520-
SDL_LogBackend("asyncio", "generic");
520+
SDL_DebugLogBackend("asyncio", "generic");
521521
CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_Generic;
522522
QuitAsyncIO = SDL_SYS_QuitAsyncIO_Generic;
523523
AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_Generic;

src/io/windows/SDL_asyncio_windows_ioring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,12 @@ static void MaybeInitializeWinIoRing(void)
511511
{
512512
if (SDL_ShouldInit(&ioring_init)) {
513513
if (LoadWinIoRing()) {
514-
SDL_LogBackend("asyncio", "ioring");
514+
SDL_DebugLogBackend("asyncio", "ioring");
515515
CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_ioring;
516516
QuitAsyncIO = SDL_SYS_QuitAsyncIO_ioring;
517517
AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_ioring;
518518
} else { // can't use ioring? Use the "generic" threadpool implementation instead.
519-
SDL_LogBackend("asyncio", "generic");
519+
SDL_DebugLogBackend("asyncio", "generic");
520520
CreateAsyncIOQueue = SDL_SYS_CreateAsyncIOQueue_Generic;
521521
QuitAsyncIO = SDL_SYS_QuitAsyncIO_Generic;
522522
AsyncIOFromFile = SDL_SYS_AsyncIOFromFile_Generic;

src/render/SDL_render.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
10641064
}
10651065

10661066
if (rc) {
1067-
SDL_LogBackend("render", renderer->name);
1067+
SDL_DebugLogBackend("render", renderer->name);
10681068
} else {
10691069
if (driver_name) {
10701070
SDL_SetError("%s not available", driver_name);

src/storage/SDL_storage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ SDL_Storage *SDL_OpenTitleStorage(const char *override, SDL_PropertiesID props)
119119
}
120120
}
121121
if (storage) {
122-
SDL_LogBackend("title_storage", titlebootstrap[i]->name);
122+
SDL_DebugLogBackend("title_storage", titlebootstrap[i]->name);
123123
} else {
124124
if (driver_name) {
125125
SDL_SetError("%s not available", driver_name);
@@ -163,7 +163,7 @@ SDL_Storage *SDL_OpenUserStorage(const char *org, const char *app, SDL_Propertie
163163
}
164164
}
165165
if (storage) {
166-
SDL_LogBackend("user_storage", userbootstrap[i]->name);
166+
SDL_DebugLogBackend("user_storage", userbootstrap[i]->name);
167167
} else {
168168
if (driver_name) {
169169
SDL_SetError("%s not available", driver_name);

0 commit comments

Comments
 (0)