11#include <SD/export.hpp>
12#include <spdlog/common.h>
13#include <spdlog/spdlog.h>
15#define ENGINE_LOG_LEVEL_TRACE 0
16#define ENGINE_LOG_LEVEL_DEBUG 1
17#define ENGINE_LOG_LEVEL_INFO 2
18#define ENGINE_LOG_LEVEL_WARN 3
19#define ENGINE_LOG_LEVEL_ERROR 4
20#define ENGINE_LOG_LEVEL_CRITICAL 5
21#define ENGINE_LOG_LEVEL_OFF 6
23#ifndef ENGINE_LOG_LEVEL
24#define ENGINE_LOG_LEVEL ENGINE_LOG_LEVEL_INFO
27#ifndef ENGINE_LOG_LEVEL_ENGINE
28#define ENGINE_LOG_LEVEL_ENGINE ENGINE_LOG_LEVEL
31#ifndef ENGINE_LOG_LEVEL_GAME
32#define ENGINE_LOG_LEVEL_GAME ENGINE_LOG_LEVEL
82 spdlog::error(
"Log category '{}' is not registered. Message was not logged.",
categoryPath);
89#define SD_LOG_CATEGORY_IMPL(CategoryPath, Level) \
90 constexpr auto cMinLevel = static_cast<::sd::log::LogLevel>(Level); \
91 constexpr const char* cCategoryPath = CategoryPath; \
93 template<typename... Args> \
94 inline void trace(spdlog::format_string_t<Args...> fmt, Args&&... args) { \
95 if constexpr (cMinLevel <= ::sd::log::LogLevel::TRACE) { \
96 if (auto logger = ::sd::log::get_category_logger_or_report(CategoryPath)) { \
97 logger->trace(fmt, std::forward<Args>(args)...); \
102 template<typename... Args> \
103 inline void debug(spdlog::format_string_t<Args...> fmt, Args&&... args) { \
104 if constexpr (cMinLevel <= ::sd::log::LogLevel::DEBUG) { \
105 if (auto logger = ::sd::log::get_category_logger_or_report(CategoryPath)) { \
106 logger->debug(fmt, std::forward<Args>(args)...); \
111 template<typename... Args> \
112 inline void info(spdlog::format_string_t<Args...> fmt, Args&&... args) { \
113 if constexpr (cMinLevel <= ::sd::log::LogLevel::INFO) { \
114 if (auto logger = ::sd::log::get_category_logger_or_report(CategoryPath)) { \
115 logger->info(fmt, std::forward<Args>(args)...); \
120 template<typename... Args> \
121 inline void warn(spdlog::format_string_t<Args...> fmt, Args&&... args) { \
122 if constexpr (cMinLevel <= ::sd::log::LogLevel::WARN) { \
123 if (auto logger = ::sd::log::get_category_logger_or_report(CategoryPath)) { \
124 logger->warn(fmt, std::forward<Args>(args)...); \
129 template<typename... Args> \
130 inline void error(spdlog::format_string_t<Args...> fmt, Args&&... args) { \
131 if constexpr (cMinLevel <= ::sd::log::LogLevel::ERROR) { \
132 if (auto logger = ::sd::log::get_category_logger_or_report(CategoryPath)) { \
133 logger->error(fmt, std::forward<Args>(args)...); \
138 template<typename... Args> \
139 inline void critical(spdlog::format_string_t<Args...> fmt, Args&&... args) { \
140 if constexpr (cMinLevel <= ::sd::log::LogLevel::CRITICAL) { \
141 if (auto logger = ::sd::log::get_category_logger_or_report(CategoryPath)) { \
142 logger->critical(fmt, std::forward<Args>(args)...); \
#define ENGINE_LOG_LEVEL_TRACE
Definition logging.hpp:15
#define ENGINE_LOG_LEVEL_WARN
Definition logging.hpp:18
#define ENGINE_LOG_LEVEL_INFO
Definition logging.hpp:17
#define ENGINE_LOG_LEVEL_OFF
Definition logging.hpp:21
#define SD_LOG_CATEGORY_IMPL(CategoryPath, Level)
Definition logging.hpp:89
#define ENGINE_LOG_LEVEL_CRITICAL
Definition logging.hpp:20
#define ENGINE_LOG_LEVEL_DEBUG
Definition logging.hpp:16
#define ENGINE_LOG_LEVEL_ENGINE
Definition logging.hpp:28
#define ENGINE_LOG_LEVEL_ERROR
Definition logging.hpp:19
Definition logging.hpp:148
Definition logging.hpp:35
LogLevel
Definition logging.hpp:37
SD_EXPORT void add_log_entry(LogEntry entry)
Definition logging.cpp:23
LogLevel from_spdlog_level(spdlog::level::level_enum level)
Definition logging.cpp:52
bool is_category_under(const std::string &child, const std::string &parent)
Definition logging.cpp:131
SD_EXPORT std::deque< LogEntry > get_log_history()
Definition logging.cpp:18
spdlog::level::level_enum to_spdlog_level(LogLevel level)
Definition logging.cpp:39
SD_EXPORT void register_category(const char *name, ImVec4 color)
Definition logging.cpp:120
SD_EXPORT void init()
Initializes all category loggers, shared sinks, and the ImGui sink.
Definition logging.cpp:138
SD_EXPORT std::vector< CategoryInfo > & get_category_registry()
Definition logging.cpp:31
std::shared_ptr< spdlog::logger > get_category_logger_or_report(const char *categoryPath)
Definition logging.hpp:77
Definition logging.hpp:54
std::string name
Definition logging.hpp:55
bool visible
Definition logging.hpp:56
ImVec4 color
Definition logging.hpp:57
Definition logging.hpp:47
std::string message
Definition logging.hpp:50
LogLevel level
Definition logging.hpp:49
float uptime_sec
Definition logging.hpp:51
std::string category
Definition logging.hpp:48
constexpr T g_type_max
Definition types.hpp:21