SDL: Added SDL_GetDefaultLogOutputFunction()

From a8ca0244951e47d3ab4343546c2cc7f9a1d996cd Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 13 Oct 2024 12:01:45 -0700
Subject: [PATCH] Added SDL_GetDefaultLogOutputFunction()

Fixes https://github.com/libsdl-org/SDL/issues/10603
Closes https://github.com/libsdl-org/SDL/pull/11106
---
 include/SDL3/SDL_log.h            | 16 ++++++++++++++++
 src/SDL_log.c                     |  5 +++++
 src/dynapi/SDL_dynapi.sym         |  1 +
 src/dynapi/SDL_dynapi_overrides.h |  1 +
 src/dynapi/SDL_dynapi_procs.h     |  1 +
 5 files changed, 24 insertions(+)

diff --git a/include/SDL3/SDL_log.h b/include/SDL3/SDL_log.h
index 8feb9e0af4cb3..180d89a76f98c 100644
--- a/include/SDL3/SDL_log.h
+++ b/include/SDL3/SDL_log.h
@@ -473,6 +473,20 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category,
  */
 typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
 
+/**
+ * Get the default log output function.
+ *
+ * \returns the default log output callback.
+ *
+ * \threadsafety It is safe to call this function from any thread.
+ *
+ * \since This function is available since SDL 3.1.6.
+ *
+ * \sa SDL_SetLogOutputFunction
+ * \sa SDL_GetLogOutputFunction
+ */
+extern SDL_DECLSPEC SDL_LogOutputFunction SDLCALL SDL_GetDefaultLogOutputFunction(void);
+
 /**
  * Get the current log output function.
  *
@@ -485,6 +499,7 @@ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_
  *
  * \since This function is available since SDL 3.0.0.
  *
+ * \sa SDL_GetDefaultLogOutputFunction
  * \sa SDL_SetLogOutputFunction
  */
 extern SDL_DECLSPEC void SDLCALL SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
@@ -499,6 +514,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetLogOutputFunction(SDL_LogOutputFunction
  *
  * \since This function is available since SDL 3.0.0.
  *
+ * \sa SDL_GetDefaultLogOutputFunction
  * \sa SDL_GetLogOutputFunction
  */
 extern SDL_DECLSPEC void SDLCALL SDL_SetLogOutputFunction(SDL_LogOutputFunction callback, void *userdata);
diff --git a/src/SDL_log.c b/src/SDL_log.c
index 1b9be017e21b0..cb619d120ed93 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -772,6 +772,11 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
 #endif
 }
 
+SDL_LogOutputFunction SDL_GetDefaultLogOutputFunction(void)
+{
+    return SDL_LogOutput;
+}
+
 void SDL_GetLogOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
 {
     SDL_LockMutex(SDL_log_function_lock);
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index c99ddd0240ff7..efa9083bcffb7 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -1180,6 +1180,7 @@ SDL3_0.0.0 {
     SDL_DelayPrecise;
     SDL_CalculateGPUTextureFormatSize;
     SDL_SetErrorV;
+    SDL_GetDefaultLogOutputFunction;
     # extra symbols go here (don't modify this line)
   local: *;
 };
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 444d20378bbdb..f5a7bb86fe6d4 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -1205,3 +1205,4 @@
 #define SDL_DelayPrecise SDL_DelayPrecise_REAL
 #define SDL_CalculateGPUTextureFormatSize SDL_CalculateGPUTextureFormatSize_REAL
 #define SDL_SetErrorV SDL_SetErrorV_REAL
+#define SDL_GetDefaultLogOutputFunction SDL_GetDefaultLogOutputFunction_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index c931a4328a46d..f5c4e29f2162d 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -1211,3 +1211,4 @@ SDL_DYNAPI_PROC(Uint32,SDL_StepBackUTF8,(const char *a, const char **b),(a,b),re
 SDL_DYNAPI_PROC(void,SDL_DelayPrecise,(Uint64 a),(a),)
 SDL_DYNAPI_PROC(Uint32,SDL_CalculateGPUTextureFormatSize,(SDL_GPUTextureFormat a, Uint32 b, Uint32 c, Uint32 d),(a,b,c,d),return)
 SDL_DYNAPI_PROC(bool,SDL_SetErrorV,(SDL_PRINTF_FORMAT_STRING const char *a,va_list b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_LogOutputFunction,SDL_GetDefaultLogOutputFunction,(void),(),return)