5#include <SDL3/SDL_log.h>
6#include "SDL3pp_stdinc.h"
75 SDL_LOG_PRIORITY_INVALID;
80 SDL_LOG_PRIORITY_VERBOSE;
91 SDL_LOG_PRIORITY_CRITICAL;
125 : m_category(category)
130 constexpr LogCategory(SDL_LogCategory category = SDL_LOG_CATEGORY_APPLICATION)
131 : m_category(category)
136 constexpr operator int() {
return m_category; }
139 constexpr operator SDL_LogCategory() {
return SDL_LogCategory(m_category); }
158 return SDL_SetLogPriorities(priority);
176 return SDL_SetLogPriority(m_category, priority);
228 return SDL_LogMessage(m_category, priority,
"%s", (
const char*)(message));
258 template<
class... ARGS>
262 std::vformat(fmt, std::make_format_args(args...)));
290 template<
class... ARGS>
291 void LogTrace(std::string_view fmt, ARGS&&... args)
const
293 return Log(SDL_LOG_PRIORITY_TRACE, fmt, std::forward<ARGS>(args)...);
322 template<
class... ARGS>
325 return Log(SDL_LOG_PRIORITY_VERBOSE, fmt, std::forward<ARGS>(args)...);
354 template<
class... ARGS>
355 void LogDebug(std::string_view fmt, ARGS&&... args)
const
357 return Log(SDL_LOG_PRIORITY_DEBUG, fmt, std::forward<ARGS>(args)...);
386 template<
class... ARGS>
387 void LogInfo(std::string_view fmt, ARGS&&... args)
const
389 return Log(SDL_LOG_PRIORITY_INFO, fmt, std::forward<ARGS>(args)...);
418 template<
class... ARGS>
419 void LogWarn(std::string_view fmt, ARGS&&... args)
const
421 return Log(SDL_LOG_PRIORITY_WARN, fmt, std::forward<ARGS>(args)...);
450 template<
class... ARGS>
451 void LogError(std::string_view fmt, ARGS&&... args)
const
453 return Log(SDL_LOG_PRIORITY_ERROR, fmt, std::forward<ARGS>(args)...);
482 template<
class... ARGS>
485 return Log(SDL_LOG_PRIORITY_CRITICAL, fmt, std::forward<ARGS>(args)...);
490 SDL_LOG_CATEGORY_APPLICATION;
511 SDL_LOG_CATEGORY_RESERVED2;
514 SDL_LOG_CATEGORY_RESERVED3;
517 SDL_LOG_CATEGORY_RESERVED4;
520 SDL_LOG_CATEGORY_RESERVED5;
523 SDL_LOG_CATEGORY_RESERVED6;
526 SDL_LOG_CATEGORY_RESERVED7;
529 SDL_LOG_CATEGORY_RESERVED8;
532 SDL_LOG_CATEGORY_RESERVED9;
535 SDL_LOG_CATEGORY_RESERVED10;
562 CheckError(SDL_SetLogPriorityPrefix(priority, prefix));
592template<
class... ARGS>
593inline void Log(std::string_view fmt, ARGS&&... args)
622 SDL_Log(
"%s",
static_cast<const char*
>(message));
675 return SDL_GetDefaultLogOutputFunction();
694 return SDL_GetLogOutputFunction(callback, userdata);
718 if (userdata ==
nullptr) {
720 cb(
nullptr, c, p, m);
723 if (
auto cb = Wrapper::at(userdata))
return cb;
725 cb(userdata, c, p, m);
746 return SDL_SetLogOutputFunction(callback, userdata);
768 SDL_SetLogOutputFunction(
770 void* userdata,
int category,
LogPriority priority,
const char* message) {
771 return Wrapper::Call(userdata,
LogCategory{category}, priority, message);
773 Wrapper::Wrap(std::move(callback)));
The predefined log categories.
Definition SDL3pp_log.h:119
void SetLogPriority(LogPriority priority)
Set the priority of a particular log category.
Definition SDL3pp_log.h:174
void LogWarn(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_WARN.
Definition SDL3pp_log.h:419
void LogUnformatted(LogPriority priority, StringParam message) const
Log an unformatted message with the specified priority.
Definition SDL3pp_log.h:226
void LogInfo(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_INFO.
Definition SDL3pp_log.h:387
constexpr LogCategory(int category)
Constructor from int.
Definition SDL3pp_log.h:124
void LogVerbose(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_VERBOSE.
Definition SDL3pp_log.h:323
void LogTrace(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_TRACE.
Definition SDL3pp_log.h:291
void LogCritical(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_CRITICAL.
Definition SDL3pp_log.h:483
LogPriority GetLogPriority() const
Get the priority of a particular log category.
Definition SDL3pp_log.h:190
void Log(LogPriority priority, std::string_view fmt, ARGS... args) const
Log a message with the specified priority.
Definition SDL3pp_log.h:259
void LogError(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_ERROR.
Definition SDL3pp_log.h:451
void LogDebug(std::string_view fmt, ARGS &&... args) const
Log a message with SDL_LOG_PRIORITY_DEBUG.
Definition SDL3pp_log.h:355
constexpr auto operator<=>(const LogCategory &other) const =default
Comparison operator.
static void ResetLogPriorities()
Reset all priorities to default.
Definition SDL3pp_log.h:204
constexpr LogCategory(SDL_LogCategory category=SDL_LOG_CATEGORY_APPLICATION)
Constructor from SDL_LogCategory.
Definition SDL3pp_log.h:130
static void SetLogPriorities(LogPriority priority)
Set the priority of all log categories.
Definition SDL3pp_log.h:156
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
constexpr LogCategory LOG_CATEGORY_ASSERT
ASSERT.
Definition SDL3pp_log.h:494
constexpr LogCategory LOG_CATEGORY_AUDIO
AUDIO.
Definition SDL3pp_log.h:498
constexpr LogCategory LOG_CATEGORY_VIDEO
VIDEO.
Definition SDL3pp_log.h:500
constexpr LogCategory LOG_CATEGORY_RESERVED10
RESERVED10.
Definition SDL3pp_log.h:534
void SetLogPriorityPrefix(LogPriority priority, StringParam prefix)
Set the text prepended to log messages of a given priority.
Definition SDL3pp_log.h:560
constexpr LogPriority LOG_PRIORITY_INVALID
INVALID.
Definition SDL3pp_log.h:74
void SetLogOutputFunction(LogOutputFunction callback, void *userdata)
Replace the default log output function with one of your own.
Definition SDL3pp_log.h:743
constexpr LogCategory LOG_CATEGORY_INPUT
INPUT.
Definition SDL3pp_log.h:504
LogOutputCB GetLogOutputFunction()
Get the current log output function.
Definition SDL3pp_log.h:712
constexpr LogCategory LOG_CATEGORY_ERROR
ERROR.
Definition SDL3pp_log.h:492
constexpr LogCategory LOG_CATEGORY_RESERVED5
RESERVED5.
Definition SDL3pp_log.h:519
void LogUnformatted(StringParam message)
Log an unformatted message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO.
Definition SDL3pp_log.h:620
void ResetLogOutputFunction()
Replace the current log output function with the default one.
Definition SDL3pp_log.h:786
constexpr LogPriority LOG_PRIORITY_CRITICAL
CRITICAL.
Definition SDL3pp_log.h:90
constexpr LogCategory LOG_CATEGORY_RESERVED8
RESERVED8.
Definition SDL3pp_log.h:528
SDL_LogPriority LogPriority
The predefined log priorities.
Definition SDL3pp_log.h:72
constexpr LogCategory LOG_CATEGORY_RESERVED7
RESERVED7.
Definition SDL3pp_log.h:525
constexpr LogPriority LOG_PRIORITY_WARN
WARN.
Definition SDL3pp_log.h:86
constexpr LogCategory LOG_CATEGORY_TEST
TEST.
Definition SDL3pp_log.h:506
constexpr LogCategory LOG_CATEGORY_RESERVED2
RESERVED2.
Definition SDL3pp_log.h:510
constexpr LogPriority LOG_PRIORITY_DEBUG
DEBUG.
Definition SDL3pp_log.h:82
void Log(std::string_view fmt, ARGS &&... args)
Log a message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO.
Definition SDL3pp_log.h:593
constexpr LogCategory LOG_CATEGORY_RENDER
RENDER.
Definition SDL3pp_log.h:502
constexpr LogCategory LOG_CATEGORY_APPLICATION
APPLICATION.
Definition SDL3pp_log.h:489
constexpr LogCategory LOG_CATEGORY_GPU
GPU.
Definition SDL3pp_log.h:508
std::function< void(LogCategory, LogPriority, const char *)> LogOutputCB
The prototype for the log output callback function.
Definition SDL3pp_log.h:659
constexpr LogCategory LOG_CATEGORY_SYSTEM
SYSTEM.
Definition SDL3pp_log.h:496
SDL_LogOutputFunction LogOutputFunction
The prototype for the log output callback function.
Definition SDL3pp_log.h:640
constexpr LogPriority LOG_PRIORITY_ERROR
ERROR.
Definition SDL3pp_log.h:88
constexpr LogPriority LOG_PRIORITY_COUNT
COUNT.
Definition SDL3pp_log.h:93
LogOutputFunction GetDefaultLogOutputFunction()
Get the default log output function.
Definition SDL3pp_log.h:673
constexpr LogPriority LOG_PRIORITY_VERBOSE
VERBOSE.
Definition SDL3pp_log.h:79
constexpr LogPriority LOG_PRIORITY_INFO
INFO.
Definition SDL3pp_log.h:84
constexpr LogCategory LOG_CATEGORY_RESERVED9
RESERVED9.
Definition SDL3pp_log.h:531
constexpr LogCategory LOG_CATEGORY_RESERVED4
RESERVED4.
Definition SDL3pp_log.h:516
constexpr LogPriority LOG_PRIORITY_TRACE
TRACE.
Definition SDL3pp_log.h:77
constexpr LogCategory LOG_CATEGORY_CUSTOM
CUSTOM.
Definition SDL3pp_log.h:537
constexpr LogCategory LOG_CATEGORY_RESERVED3
RESERVED3.
Definition SDL3pp_log.h:513
constexpr LogCategory LOG_CATEGORY_RESERVED6
RESERVED6.
Definition SDL3pp_log.h:522
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Stored Wrapper unique by type result callbacks.
Definition SDL3pp_callbackWrapper.h:242