Module log

Available on crate feature dep_sdl3 only.
Expand description

Simple log messages with priorities and categories. A message’s SDL_LogPriority signifies how important the message is. A message’s SDL_LogCategory signifies from what domain it belongs to. Every category has a minimum priority specified: when a message belongs to that category, it will only be sent out if it has that minimum priority or higher.

SDL’s own logs are sent below the default priority threshold, so they are quiet by default.

You can change the log verbosity programmatically using SDL_SetLogPriority() or with SDL_SetHint([SDL_HINT_LOGGING], …), or with the “SDL_LOGGING” environment variable. This variable is a comma separated set of category=level tokens that define the default logging levels for SDL applications.

The category can be a numeric category, one of “app”, “error”, “assert”, “system”, “audio”, “video”, “render”, “input”, “test”, or * for any unspecified category.

The level can be a numeric level, one of “verbose”, “debug”, “info”, “warn”, “error”, “critical”, or “quiet” to disable that category.

You can omit the category if you want to set the logging level for all categories.

If this hint isn’t set, the default log levels are equivalent to:

app=info,assert=warn,test=verbose,*=error

Here’s where the messages go on different platforms:

  • Windows: debug output stream
  • Android: log output
  • Others: standard error output (stderr)

You don’t need to have a newline (\n) on the end of messages, the functions will do that for you. For consistent behavior cross-platform, you shouldn’t have any newlines in messages, such as to log multiple lines in one call; unusual platform-specific behavior can be observed in such usage. Do one log call per line instead, with no newlines in messages.

Each log call is atomic, so you won’t see log messages cut off one another when logging from multiple threads.

Structs§

SDL_LogCategory
The predefined log categories
SDL_LogPriority
The predefined log priorities

Constants§

SDL_LOG_CATEGORY_APPLICATION
SDL_LOG_CATEGORY_ASSERT
SDL_LOG_CATEGORY_AUDIO
SDL_LOG_CATEGORY_CUSTOM
SDL_LOG_CATEGORY_ERROR
SDL_LOG_CATEGORY_GPU
SDL_LOG_CATEGORY_INPUT
SDL_LOG_CATEGORY_RENDER
SDL_LOG_CATEGORY_RESERVED2
SDL_LOG_CATEGORY_RESERVED3
SDL_LOG_CATEGORY_RESERVED4
SDL_LOG_CATEGORY_RESERVED5
SDL_LOG_CATEGORY_RESERVED6
SDL_LOG_CATEGORY_RESERVED7
SDL_LOG_CATEGORY_RESERVED8
SDL_LOG_CATEGORY_RESERVED9
SDL_LOG_CATEGORY_RESERVED10
SDL_LOG_CATEGORY_SYSTEM
SDL_LOG_CATEGORY_TEST
SDL_LOG_CATEGORY_VIDEO
SDL_LOG_PRIORITY_COUNT
SDL_LOG_PRIORITY_CRITICAL
SDL_LOG_PRIORITY_DEBUG
SDL_LOG_PRIORITY_ERROR
SDL_LOG_PRIORITY_INFO
SDL_LOG_PRIORITY_INVALID
SDL_LOG_PRIORITY_TRACE
SDL_LOG_PRIORITY_VERBOSE
SDL_LOG_PRIORITY_WARN

Functions§

SDL_GetDefaultLogOutputFunction
Get the default log output function.
SDL_GetLogOutputFunction
Get the current log output function.
SDL_GetLogPriority
Get the priority of a particular log category.
SDL_Log
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
SDL_LogCritical
Log a message with SDL_LOG_PRIORITY_CRITICAL.
SDL_LogDebug
Log a message with SDL_LOG_PRIORITY_DEBUG.
SDL_LogError
Log a message with SDL_LOG_PRIORITY_ERROR.
SDL_LogInfo
Log a message with SDL_LOG_PRIORITY_INFO.
SDL_LogMessage
Log a message with the specified category and priority.
SDL_LogMessageV
Log a message with the specified category and priority.
SDL_LogTrace
Log a message with SDL_LOG_PRIORITY_TRACE.
SDL_LogVerbose
Log a message with SDL_LOG_PRIORITY_VERBOSE.
SDL_LogWarn
Log a message with SDL_LOG_PRIORITY_WARN.
SDL_ResetLogPriorities
Reset all priorities to default.
SDL_SetLogOutputFunction
Replace the default log output function with one of your own.
SDL_SetLogPriorities
Set the priority of all log categories.
SDL_SetLogPriority
Set the priority of a particular log category.
SDL_SetLogPriorityPrefix
Set the text prepended to log messages of a given priority.

Type Aliases§

SDL_LogOutputFunction
The prototype for the log output callback function.