5#include <SDL3/SDL_log.h>
6#include "SDL3pp_callbackWrapper.h"
7#include "SDL3pp_error.h"
8#include "SDL3pp_strings.h"
84 SDL_LOG_PRIORITY_INVALID;
89 SDL_LOG_PRIORITY_VERBOSE;
100 SDL_LOG_PRIORITY_CRITICAL;
138 : m_category(category)
148 : m_category(SDL_LogCategory(category))
209 SDL_LogMessage(m_category, priority,
"%s", (
const char*)(message));
237 template<
class... ARGS>
239 std::string_view fmt,
266 template<
class... ARGS>
267 void LogTrace(std::string_view fmt, ARGS&&... args)
const;
292 template<
class... ARGS>
293 void LogVerbose(std::string_view fmt, ARGS&&... args)
const;
319 template<
class... ARGS>
320 void LogDebug(std::string_view fmt, ARGS&&... args)
const;
346 template<
class... ARGS>
347 void LogInfo(std::string_view fmt, ARGS&&... args)
const;
373 template<
class... ARGS>
374 void LogWarn(std::string_view fmt, ARGS&&... args)
const;
400 template<
class... ARGS>
401 void LogError(std::string_view fmt, ARGS&&... args)
const;
428 template<
class... ARGS>
429 void LogCritical(std::string_view fmt, ARGS&&... args)
const;
433 SDL_LOG_CATEGORY_APPLICATION;
454 SDL_LOG_CATEGORY_RESERVED2;
457 SDL_LOG_CATEGORY_RESERVED3;
460 SDL_LOG_CATEGORY_RESERVED4;
463 SDL_LOG_CATEGORY_RESERVED5;
466 SDL_LOG_CATEGORY_RESERVED6;
469 SDL_LOG_CATEGORY_RESERVED7;
472 SDL_LOG_CATEGORY_RESERVED8;
475 SDL_LOG_CATEGORY_RESERVED9;
478 SDL_LOG_CATEGORY_RESERVED10;
496 SDL_SetLogPriorities(priority);
515 SDL_SetLogPriority(category, priority);
537 return SDL_GetLogPriority(category);
579 CheckError(SDL_SetLogPriorityPrefix(priority, prefix));
608 SDL_LogMessage(category, priority,
"%s",
static_cast<const char*
>(message));
633 SDL_Log(
"%s",
static_cast<const char*
>(message));
663template<
class... ARGS>
664inline void Log(std::string_view fmt, ARGS&&... args)
692template<
class... ARGS>
695 std::string_view fmt,
699 category, priority, std::vformat(fmt, std::make_format_args(args...)));
702template<
class... ARGS>
704 std::string_view fmt,
733template<
class... ARGS>
739template<
class... ARGS>
766template<
class... ARGS>
768 std::string_view fmt,
774template<
class... ARGS>
802template<
class... ARGS>
808template<
class... ARGS>
836template<
class... ARGS>
842template<
class... ARGS>
870template<
class... ARGS>
873 LogMessage(category, SDL_LOG_PRIORITY_WARN, fmt, args...);
876template<
class... ARGS>
904template<
class... ARGS>
907 LogMessage(category, SDL_LOG_PRIORITY_ERROR, fmt, args...);
910template<
class... ARGS>
938template<
class... ARGS>
940 std::string_view fmt,
943 LogMessage(category, SDL_LOG_PRIORITY_CRITICAL, fmt, args...);
946template<
class... ARGS>
1001 return SDL_GetDefaultLogOutputFunction();
1020 SDL_GetLogOutputFunction(callback, userdata);
1044 if (userdata ==
nullptr) {
1046 cb(
nullptr, c, p, m);
1049 if (
auto cb = Wrapper::at(userdata))
return cb;
1051 cb(userdata, c, p, m);
1072 return SDL_SetLogOutputFunction(callback, userdata);
1094 SDL_SetLogOutputFunction(
1096 void* userdata,
int category,
LogPriority priority,
const char* message) {
1097 return Wrapper::Call(userdata,
LogCategory{category}, priority, message);
1099 Wrapper::Wrap(std::move(callback)));
The predefined log categories.
Definition: SDL3pp_log.h:128
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:197
void SetLogPriorities(LogPriority priority)
Set the priority of all log categories.
Definition: SDL3pp_log.h:494
constexpr LogCategory LOG_CATEGORY_ASSERT
ASSERT.
Definition: SDL3pp_log.h:437
constexpr LogCategory LOG_CATEGORY_AUDIO
AUDIO.
Definition: SDL3pp_log.h:441
void LogWarn(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_WARN.
Definition: SDL3pp_log.h:877
constexpr LogCategory LOG_CATEGORY_VIDEO
VIDEO.
Definition: SDL3pp_log.h:443
SDL_LogCategory LogCategoryRaw
Alias to raw representation for LogCategory.
Definition: SDL3pp_log.h:63
constexpr LogCategory LOG_CATEGORY_RESERVED10
RESERVED10.
Definition: SDL3pp_log.h:477
void LogVerbose(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_VERBOSE.
Definition: SDL3pp_log.h:767
void SetLogPriorityPrefix(LogPriority priority, StringParam prefix)
Set the text prepended to log messages of a given priority.
Definition: SDL3pp_log.h:577
LogPriority GetLogPriority(int category)
Get the priority of a particular log category.
Definition: SDL3pp_log.h:535
void SetLogPriority(int category, LogPriority priority)
Set the priority of a particular log category.
Definition: SDL3pp_log.h:513
void LogTrace(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_TRACE.
Definition: SDL3pp_log.h:734
void LogUnformatted(LogPriority priority, StringParam message) const
Log an unformatted message with the specified priority.
Definition: SDL3pp_log.h:207
constexpr LogPriority LOG_PRIORITY_INVALID
INVALID.
Definition: SDL3pp_log.h:83
void SetLogOutputFunction(LogOutputFunction callback, void *userdata)
Replace the default log output function with one of your own.
Definition: SDL3pp_log.h:1069
constexpr LogCategory LOG_CATEGORY_INPUT
INPUT.
Definition: SDL3pp_log.h:447
LogOutputCB GetLogOutputFunction()
Get the current log output function.
Definition: SDL3pp_log.h:1038
constexpr LogCategory LOG_CATEGORY_ERROR
ERROR.
Definition: SDL3pp_log.h:435
void LogInfo(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_INFO.
Definition: SDL3pp_log.h:843
constexpr LogCategory(int category)
Wraps LogCategory.
Definition: SDL3pp_log.h:147
constexpr LogCategory LOG_CATEGORY_RESERVED5
RESERVED5.
Definition: SDL3pp_log.h:462
void LogVerbose(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_VERBOSE.
Definition: SDL3pp_log.h:775
void LogCritical(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_CRITICAL.
Definition: SDL3pp_log.h:939
void LogTrace(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_TRACE.
Definition: SDL3pp_log.h:740
void ResetLogOutputFunction()
Replace the current log output function with the default one.
Definition: SDL3pp_log.h:1112
constexpr LogPriority LOG_PRIORITY_CRITICAL
CRITICAL.
Definition: SDL3pp_log.h:99
void LogCritical(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_CRITICAL.
Definition: SDL3pp_log.h:947
void LogDebug(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_DEBUG.
Definition: SDL3pp_log.h:803
constexpr LogCategory LOG_CATEGORY_RESERVED8
RESERVED8.
Definition: SDL3pp_log.h:471
LogPriority GetLogPriority() const
Get the priority of a particular log category.
Definition: SDL3pp_log.h:540
SDL_LogPriority LogPriority
The predefined log priorities.
Definition: SDL3pp_log.h:81
void LogError(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_ERROR.
Definition: SDL3pp_log.h:911
constexpr LogCategory LOG_CATEGORY_RESERVED7
RESERVED7.
Definition: SDL3pp_log.h:468
constexpr LogPriority LOG_PRIORITY_WARN
WARN.
Definition: SDL3pp_log.h:95
void LogUnformatted(LogCategory category, LogPriority priority, StringParam message)
Log an unformatted message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO.
Definition: SDL3pp_log.h:604
void LogMessage(LogPriority priority, std::string_view fmt, ARGS... args) const
Log a message with the specified priority.
Definition: SDL3pp_log.h:703
void LogDebug(std::string_view fmt, ARGS &&... args) const
Log a message with LOG_PRIORITY_DEBUG.
Definition: SDL3pp_log.h:809
void LogError(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_ERROR.
Definition: SDL3pp_log.h:905
constexpr LogCategory LOG_CATEGORY_TEST
TEST.
Definition: SDL3pp_log.h:449
constexpr LogCategory LOG_CATEGORY_RESERVED2
RESERVED2.
Definition: SDL3pp_log.h:453
constexpr LogPriority LOG_PRIORITY_DEBUG
DEBUG.
Definition: SDL3pp_log.h:91
void LogMessage(LogCategory category, LogPriority priority, std::string_view fmt, ARGS... args)
Log a message with the specified category and priority.
Definition: SDL3pp_log.h:693
void Log(std::string_view fmt, ARGS &&... args)
Log a message with LOG_CATEGORY_APPLICATION and LOG_PRIORITY_INFO.
Definition: SDL3pp_log.h:664
constexpr LogCategory LOG_CATEGORY_RENDER
RENDER.
Definition: SDL3pp_log.h:445
constexpr LogCategory LOG_CATEGORY_APPLICATION
APPLICATION.
Definition: SDL3pp_log.h:432
constexpr LogCategory LOG_CATEGORY_GPU
GPU.
Definition: SDL3pp_log.h:451
std::function< void(LogCategory, LogPriority, const char *)> LogOutputCB
The prototype for the log output callback function.
Definition: SDL3pp_log.h:985
void LogInfo(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_INFO.
Definition: SDL3pp_log.h:837
constexpr LogCategory LOG_CATEGORY_SYSTEM
SYSTEM.
Definition: SDL3pp_log.h:439
void SetLogPriority(LogPriority priority) const
Set the priority of a particular log category.
Definition: SDL3pp_log.h:518
SDL_LogOutputFunction LogOutputFunction
The prototype for the log output callback function.
Definition: SDL3pp_log.h:966
void ResetLogPriorities()
Reset all priorities to default.
Definition: SDL3pp_log.h:557
constexpr LogPriority LOG_PRIORITY_ERROR
ERROR.
Definition: SDL3pp_log.h:97
constexpr LogPriority LOG_PRIORITY_COUNT
COUNT.
Definition: SDL3pp_log.h:102
void LogWarn(LogCategory category, std::string_view fmt, ARGS &&... args)
Log a message with LOG_PRIORITY_WARN.
Definition: SDL3pp_log.h:871
LogOutputFunction GetDefaultLogOutputFunction()
Get the default log output function.
Definition: SDL3pp_log.h:999
constexpr LogPriority LOG_PRIORITY_VERBOSE
VERBOSE.
Definition: SDL3pp_log.h:88
constexpr LogPriority LOG_PRIORITY_INFO
INFO.
Definition: SDL3pp_log.h:93
constexpr LogCategory LOG_CATEGORY_RESERVED9
RESERVED9.
Definition: SDL3pp_log.h:474
constexpr LogCategory LOG_CATEGORY_RESERVED4
RESERVED4.
Definition: SDL3pp_log.h:459
constexpr LogPriority LOG_PRIORITY_TRACE
TRACE.
Definition: SDL3pp_log.h:86
constexpr LogCategory LOG_CATEGORY_CUSTOM
CUSTOM.
Definition: SDL3pp_log.h:480
constexpr LogCategory(LogCategoryRaw category=SDL_LOG_CATEGORY_APPLICATION)
Wraps LogCategory.
Definition: SDL3pp_log.h:137
constexpr LogCategory LOG_CATEGORY_RESERVED3
RESERVED3.
Definition: SDL3pp_log.h:456
constexpr LogCategory LOG_CATEGORY_RESERVED6
RESERVED6.
Definition: SDL3pp_log.h:465
Main include header for the SDL3pp library.
Stored Wrapper unique by type result callbacks.
Definition: SDL3pp_callbackWrapper.h:242