mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-20 15:51:07 +01:00
Improve logging performance and make log priorities thread-safe
Fixes https://github.com/libsdl-org/SDL/issues/9679
This commit is contained in:
@@ -120,7 +120,8 @@ typedef enum SDL_LogCategory
|
||||
*/
|
||||
typedef enum SDL_LogPriority
|
||||
{
|
||||
SDL_LOG_PRIORITY_VERBOSE = 1,
|
||||
SDL_LOG_PRIORITY_INVALID,
|
||||
SDL_LOG_PRIORITY_VERBOSE,
|
||||
SDL_LOG_PRIORITY_DEBUG,
|
||||
SDL_LOG_PRIORITY_INFO,
|
||||
SDL_LOG_PRIORITY_WARN,
|
||||
@@ -135,6 +136,8 @@ typedef enum SDL_LogPriority
|
||||
*
|
||||
* \param priority the SDL_LogPriority to assign.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ResetLogPriorities
|
||||
@@ -148,14 +151,15 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriorities(SDL_LogPriority priority);
|
||||
* \param category the category to assign a priority to.
|
||||
* \param priority the SDL_LogPriority to assign.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetLogPriority
|
||||
* \sa SDL_ResetLogPriorities
|
||||
* \sa SDL_SetLogPriorities
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category,
|
||||
SDL_LogPriority priority);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category, SDL_LogPriority priority);
|
||||
|
||||
/**
|
||||
* Get the priority of a particular log category.
|
||||
@@ -163,6 +167,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetLogPriority(int category,
|
||||
* \param category the category to query.
|
||||
* \returns the SDL_LogPriority for the requested category.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetLogPriority
|
||||
@@ -174,6 +180,8 @@ extern SDL_DECLSPEC SDL_LogPriority SDLCALL SDL_GetLogPriority(int category);
|
||||
*
|
||||
* This is called by SDL_Quit().
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetLogPriorities
|
||||
@@ -194,6 +202,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void);
|
||||
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetLogPriorities
|
||||
@@ -208,6 +218,8 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority pr
|
||||
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||
* any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_LogCritical
|
||||
@@ -229,6 +241,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fm
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -250,6 +264,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -271,6 +287,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_ST
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -292,6 +310,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STR
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -313,6 +333,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STR
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -334,6 +356,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_ST
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -356,6 +380,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT
|
||||
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||
* if any.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -379,6 +405,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessage(int category,
|
||||
* \param fmt a printf() style message format string.
|
||||
* \param ap a variable argument list.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_Log
|
||||
@@ -397,7 +425,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LogMessageV(int category,
|
||||
/**
|
||||
* The prototype for the log output callback function.
|
||||
*
|
||||
* This function is called by SDL when there is new text to be logged.
|
||||
* This function is called by SDL when there is new text to be logged. A mutex is held so that this function is never called by more than one thread at once.
|
||||
*
|
||||
* \param userdata what was passed as `userdata` to
|
||||
* SDL_SetLogOutputFunction().
|
||||
@@ -417,6 +445,8 @@ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_
|
||||
* \param userdata a pointer filled in with the pointer that is passed to
|
||||
* `callback`.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetLogOutputFunction
|
||||
@@ -429,6 +459,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetLogOutputFunction(SDL_LogOutputFunction
|
||||
* \param callback an SDL_LogOutputFunction to call instead of the default.
|
||||
* \param userdata a pointer that is passed to `callback`.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetLogOutputFunction
|
||||
|
||||
Reference in New Issue
Block a user