27template<
typename... Args>
29 const char* func, std::format_string<Args...> fmt, Args&&... args)
31 std::string message = std::format(fmt, std::forward<Args>(args)...);
32 std::string fullMessage = std::format(
"[{}] {}", category.
getName(), message);
37 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::fatal).printf(
"%s", fullMessage.c_str());
40 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::error).printf(
"%s", fullMessage.c_str());
43 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::warning).printf(
"%s", fullMessage.c_str());
46 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::info).printf(
"%s", fullMessage.c_str());
49 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::debug).printf(
"%s", fullMessage.c_str());
52 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::verbose).printf(
"%s", fullMessage.c_str());
61 const char* func,
const char* message)
63 std::string fullMessage = std::format(
"[{}] {}", category.
getName(), message);
67 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::fatal).printf(
"%s", fullMessage.c_str());
70 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::error).printf(
"%s", fullMessage.c_str());
73 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::warning).printf(
"%s", fullMessage.c_str());
76 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::info).printf(
"%s", fullMessage.c_str());
79 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::debug).printf(
"%s", fullMessage.c_str());
82 PLOG_(PLOG_DEFAULT_INSTANCE_ID, plog::verbose).printf(
"%s", fullMessage.c_str());
99#ifndef VS_LOG_COMPILE_TIME_VERBOSITY
101 #define VS_LOG_COMPILE_TIME_VERBOSITY ::EngineCore::LogVerbosity::Info
103 #define VS_LOG_COMPILE_TIME_VERBOSITY ::EngineCore::LogVerbosity::Verbose
122#define VS_LOG(Category, Verbosity, Format, ...) \
124 if constexpr (static_cast<uint8_t>(::EngineCore::LogVerbosity::Verbosity) <= \
125 static_cast<uint8_t>(VS_LOG_COMPILE_TIME_VERBOSITY)) { \
126 if (!Category.isSuppressed(::EngineCore::LogVerbosity::Verbosity)) { \
127 ::EngineCore::logImpl(Category, ::EngineCore::LogVerbosity::Verbosity, \
128 __FILE__, __LINE__, __func__, Format __VA_OPT__(,) __VA_ARGS__); \
138#define VS_LOG_SIMPLE(Category, Verbosity, Message) \
140 if constexpr (static_cast<uint8_t>(::EngineCore::LogVerbosity::Verbosity) <= \
141 static_cast<uint8_t>(VS_LOG_COMPILE_TIME_VERBOSITY)) { \
142 if (!Category.isSuppressed(::EngineCore::LogVerbosity::Verbosity)) { \
143 ::EngineCore::logImplSimple(Category, ::EngineCore::LogVerbosity::Verbosity, \
144 __FILE__, __LINE__, __func__, Message); \
158#define VS_CLOG(Condition, Category, Verbosity, Format, ...) \
161 VS_LOG(Category, Verbosity, Format __VA_OPT__(,) __VA_ARGS__); \
168#define VS_LOG_ONCE(Category, Verbosity, Format, ...) \
170 static bool _vs_logged_once = false; \
171 if (!_vs_logged_once) { \
172 _vs_logged_once = true; \
173 VS_LOG(Category, Verbosity, Format __VA_OPT__(,) __VA_ARGS__); \
181#define VS_LOG_FATAL(Category, Format, ...) VS_LOG(Category, Fatal, Format __VA_OPT__(,) __VA_ARGS__)
182#define VS_LOG_ERROR(Category, Format, ...) VS_LOG(Category, Error, Format __VA_OPT__(,) __VA_ARGS__)
183#define VS_LOG_WARNING(Category, Format, ...) VS_LOG(Category, Warning, Format __VA_OPT__(,) __VA_ARGS__)
184#define VS_LOG_INFO(Category, Format, ...) VS_LOG(Category, Info, Format __VA_OPT__(,) __VA_ARGS__)
185#define VS_LOG_DEBUG(Category, Format, ...) VS_LOG(Category, Debug, Format __VA_OPT__(,) __VA_ARGS__)
186#define VS_LOG_VERBOSE(Category, Format, ...) VS_LOG(Category, Verbose, Format __VA_OPT__(,) __VA_ARGS__)
Represents a single log category with verbosity control.
const char * getName() const
Get the category name.
Log category system implementation.
void logImplSimple(LogCategory &category, LogVerbosity verbosity, const char *file, int line, const char *func, const char *message)
Internal helper for messages without format arguments.
void logImpl(LogCategory &category, LogVerbosity verbosity, const char *file, int line, const char *func, std::format_string< Args... > fmt, Args &&... args)
Internal helper to format and output a log message.
LogVerbosity
Log verbosity levels, ordered from most to least severe.
@ Warning
Potential issue.
@ Info
Important state changes.
@ Fatal
Unrecoverable error, may crash.
@ Error
Recoverable error.
@ Debug
Development debugging.
@ Verbose
Detailed tracing.