|
SDL3pp
A slim C++ wrapper for SDL3
|
Simple log messages with priorities and categories. More...

Classes | |
| class | SDL::LogCategory |
| The predefined log categories. More... | |
Typedefs | |
| using | SDL::LogCategoryRaw = SDL_LogCategory |
| Alias to raw representation for LogCategory. | |
Functions | |
| constexpr | SDL::LogCategory::LogCategory (LogCategoryRaw category=SDL_LOG_CATEGORY_APPLICATION) |
| Wraps LogCategory. More... | |
| constexpr | SDL::LogCategory::LogCategory (int category) |
| Wraps LogCategory. More... | |
| constexpr | SDL::LogCategory::operator LogCategoryRaw () const |
| Unwraps to the underlying LogCategory. More... | |
| void | SDL::LogCategory::LogUnformatted (LogPriority priority, StringParam message) const |
| Log an unformatted message with the specified priority. More... | |
LogPriorities | |
The priorities assignable for a LogCategory. | |
| using | SDL::LogPriority = SDL_LogPriority |
| The predefined log priorities. More... | |
| constexpr LogPriority | SDL::LOG_PRIORITY_INVALID |
| INVALID. More... | |
| constexpr LogPriority | SDL::LOG_PRIORITY_TRACE = SDL_LOG_PRIORITY_TRACE |
| TRACE. | |
| constexpr LogPriority | SDL::LOG_PRIORITY_VERBOSE |
| VERBOSE. More... | |
| constexpr LogPriority | SDL::LOG_PRIORITY_DEBUG = SDL_LOG_PRIORITY_DEBUG |
| DEBUG. | |
| constexpr LogPriority | SDL::LOG_PRIORITY_INFO = SDL_LOG_PRIORITY_INFO |
| INFO. | |
| constexpr LogPriority | SDL::LOG_PRIORITY_WARN = SDL_LOG_PRIORITY_WARN |
| WARN. | |
| constexpr LogPriority | SDL::LOG_PRIORITY_ERROR = SDL_LOG_PRIORITY_ERROR |
| ERROR. | |
| constexpr LogPriority | SDL::LOG_PRIORITY_CRITICAL |
| CRITICAL. More... | |
| constexpr LogPriority | SDL::LOG_PRIORITY_COUNT = SDL_LOG_PRIORITY_COUNT |
| COUNT. | |
LogCategories | |
The logging categories. see LogCategory for more info | |
| using | SDL::LogOutputFunction = SDL_LogOutputFunction |
| The prototype for the log output callback function. More... | |
| using | SDL::LogOutputCB = std::function< void(LogCategory, LogPriority, const char *)> |
| The prototype for the log output callback function. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_APPLICATION |
| APPLICATION. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_ERROR = SDL_LOG_CATEGORY_ERROR |
| ERROR. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_ASSERT = SDL_LOG_CATEGORY_ASSERT |
| ASSERT. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_SYSTEM = SDL_LOG_CATEGORY_SYSTEM |
| SYSTEM. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_AUDIO = SDL_LOG_CATEGORY_AUDIO |
| AUDIO. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_VIDEO = SDL_LOG_CATEGORY_VIDEO |
| VIDEO. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RENDER = SDL_LOG_CATEGORY_RENDER |
| RENDER. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_INPUT = SDL_LOG_CATEGORY_INPUT |
| INPUT. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_TEST = SDL_LOG_CATEGORY_TEST |
| TEST. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_GPU = SDL_LOG_CATEGORY_GPU |
| GPU. | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED2 |
| RESERVED2. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED3 |
| RESERVED3. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED4 |
| RESERVED4. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED5 |
| RESERVED5. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED6 |
| RESERVED6. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED7 |
| RESERVED7. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED8 |
| RESERVED8. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED9 |
| RESERVED9. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_RESERVED10 |
| RESERVED10. More... | |
| constexpr LogCategory | SDL::LOG_CATEGORY_CUSTOM = SDL_LOG_CATEGORY_CUSTOM |
| CUSTOM. | |
| void | SDL::LogCategory::SetLogPriority (LogPriority priority) const |
| Set the priority of a particular log category. More... | |
| LogPriority | SDL::LogCategory::GetLogPriority () const |
| Get the priority of a particular log category. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogMessage (LogPriority priority, std::string_view fmt, ARGS... args) const |
| Log a message with the specified priority. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogTrace (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_TRACE. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogVerbose (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_VERBOSE. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogDebug (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_DEBUG. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogInfo (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_INFO. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogWarn (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_WARN. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogError (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_ERROR. More... | |
| template<class... ARGS> | |
| void | SDL::LogCategory::LogCritical (std::string_view fmt, ARGS &&... args) const |
| Log a message with LOG_PRIORITY_CRITICAL. More... | |
| void | SDL::SetLogPriorities (LogPriority priority) |
| Set the priority of all log categories. More... | |
| void | SDL::SetLogPriority (int category, LogPriority priority) |
| Set the priority of a particular log category. More... | |
| LogPriority | SDL::GetLogPriority (int category) |
| Get the priority of a particular log category. More... | |
| void | SDL::ResetLogPriorities () |
| Reset all priorities to default. More... | |
| void | SDL::SetLogPriorityPrefix (LogPriority priority, StringParam prefix) |
| Set the text prepended to log messages of a given priority. More... | |
| void | SDL::LogUnformatted (LogCategory category, LogPriority priority, StringParam message) |
| Log an unformatted message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO. More... | |
| void | SDL::LogUnformatted (StringParam message) |
| Log an unformatted message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO. More... | |
| template<class... ARGS> | |
| void | SDL::Log (std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO. More... | |
| template<class... ARGS> | |
| void | SDL::LogMessage (LogCategory category, LogPriority priority, std::string_view fmt, ARGS... args) |
| Log a message with the specified category and priority. More... | |
| template<class... ARGS> | |
| void | SDL::LogTrace (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_TRACE. More... | |
| template<class... ARGS> | |
| void | SDL::LogVerbose (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_VERBOSE. More... | |
| template<class... ARGS> | |
| void | SDL::LogDebug (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_DEBUG. More... | |
| template<class... ARGS> | |
| void | SDL::LogInfo (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_INFO. More... | |
| template<class... ARGS> | |
| void | SDL::LogWarn (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_WARN. More... | |
| template<class... ARGS> | |
| void | SDL::LogError (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_ERROR. More... | |
| template<class... ARGS> | |
| void | SDL::LogCritical (LogCategory category, std::string_view fmt, ARGS &&... args) |
| Log a message with LOG_PRIORITY_CRITICAL. More... | |
| LogOutputFunction | SDL::GetDefaultLogOutputFunction () |
| Get the default log output function. More... | |
| void | SDL::GetLogOutputFunction (LogOutputFunction *callback, void **userdata) |
| Get the current log output function. More... | |
| LogOutputCB | SDL::GetLogOutputFunction () |
| Get the current log output function. More... | |
| void | SDL::SetLogOutputFunction (LogOutputFunction callback, void *userdata) |
| Replace the default log output function with one of your own. More... | |
| void | SDL::SetLogOutputFunction (LogOutputCB callback) |
| Replace the default log output function with one of your own. More... | |
| void | SDL::ResetLogOutputFunction () |
| Replace the current log output function with the default one. More... | |
A message's LogPriority signifies how important the message is. A message's 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 LogCategory.SetLogPriority() or with 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 "trace", "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:
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.
| using SDL::LogOutputCB = typedef std::function<void(LogCategory, LogPriority, const char*)> |
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.
| category | the category of the message. |
| priority | the priority of the message. |
| message | the message being output. |
| using SDL::LogOutputFunction = typedef SDL_LogOutputFunction |
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.
| userdata | what was passed as userdata to SetLogOutputFunction(). |
| category | the category of the message. |
| priority | the priority of the message. |
| message | the message being output. |
| using SDL::LogPriority = typedef SDL_LogPriority |
|
inline |
|
inline |
|
inline |
| callback | an LogOutputFunction filled in with the current log callback. |
| userdata | a pointer filled in with the pointer that is passed to callback. |
|
inline |
|
inline |
| category | the category to query. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inlineexplicitconstexpr |
| category | the value to be wrapped |
|
inlineconstexpr |
| category | the value to be wrapped |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| priority | the priority of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| priority | the priority of the message. |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| priority | the priority of the message. |
| message | string to output. |
|
inline |
| priority | the priority of the message. |
| message | string to output. |
|
inline |
| message | string to output. |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inline |
| category | the category of the message. |
| fmt | a printf() style message format string. |
| args | additional parameters matching % tokens in the fmt string, if any. |
|
inline |
| fmt | a std::format/fmt style message format string. |
| args | additional parameters matching the {} tokens in the format string, if any. |
|
inlineconstexpr |
|
inline |
|
inline |
|
inline |
| callback | an LogOutputFunction to call instead of the default. |
|
inline |
| callback | an LogOutputFunction to call instead of the default. |
| userdata | a pointer that is passed to callback. |
|
inline |
| priority | the LogPriority to assign. |
|
inline |
| category | the category to assign a priority to. |
| priority | the LogPriority to assign. |
|
inline |
| priority | the LogPriority to assign. |
|
inline |
By default LOG_PRIORITY_INFO and below have no prefix, and LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. "WARNING: ".
| priority | the LogPriority to modify. |
| prefix | the prefix to use for that log priority, or nullptr to use no prefix. |
| Error | on failure. |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |