sdlSetLogPriorityPrefix function

bool sdlSetLogPriorityPrefix(
  1. int priority,
  2. String? prefix
)

Set the text prepended to log messages of a given priority.

By default SDL_LOG_PRIORITY_INFO and below have no prefix, and SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. "WARNING: ".

\param priority the SDL_LogPriority to modify. \param prefix the prefix to use for that log priority, or NULL to use no prefix. \returns true on success or 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.1.3.

\sa SDL_SetLogPriorities \sa SDL_SetLogPriority

extern SDL_DECLSPEC bool SDLCALL SDL_SetLogPriorityPrefix(SDL_LogPriority priority, const char *prefix)

Implementation

bool sdlSetLogPriorityPrefix(int priority, String? prefix) {
  final sdlSetLogPriorityPrefixLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Int32 priority, Pointer<Utf8> prefix),
      int Function(
          int priority, Pointer<Utf8> prefix)>('SDL_SetLogPriorityPrefix');
  final prefixPointer = prefix != null ? prefix.toNativeUtf8() : nullptr;
  final result =
      sdlSetLogPriorityPrefixLookupFunction(priority, prefixPointer) == 1;
  calloc.free(prefixPointer);
  return result;
}