aboutsummaryrefslogtreecommitdiff
path: root/zencore
diff options
context:
space:
mode:
Diffstat (limited to 'zencore')
-rw-r--r--zencore/include/zencore/logging.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h
index 468e5d6e2..74ab0f81f 100644
--- a/zencore/include/zencore/logging.h
+++ b/zencore/include/zencore/logging.h
@@ -38,6 +38,67 @@ using logging::ConsoleLog;
using zen::ConsoleLog;
using zen::Log;
+struct LogCategory
+{
+ LogCategory(std::string_view InCategory) : Category(InCategory) {}
+
+ spdlog::logger& Logger()
+ {
+ static spdlog::logger& Inst = zen::logging::Get(Category);
+ return Inst;
+ }
+
+ std::string Category;
+};
+
+#define ZEN_DEFINE_LOG_CATEGORY_STATIC(Category, Name) \
+ static struct LogCategory##Category : public LogCategory \
+ { \
+ LogCategory##Category() : LogCategory(Name) {} \
+ } Category;
+
+#define ZEN_LOG_TRACE(Category, fmtstr, ...) \
+ do \
+ { \
+ using namespace std::literals; \
+ Category.Logger().trace(fmtstr##sv, ##__VA_ARGS__); \
+ } while (false)
+
+#define ZEN_LOG_DEBUG(Category, fmtstr, ...) \
+ do \
+ { \
+ using namespace std::literals; \
+ Category.Logger().debug(fmtstr##sv, ##__VA_ARGS__); \
+ } while (false)
+
+#define ZEN_LOG_INFO(Category, fmtstr, ...) \
+ do \
+ { \
+ using namespace std::literals; \
+ Category.Logger().info(fmtstr##sv, ##__VA_ARGS__); \
+ } while (false)
+
+#define ZEN_LOG_WARN(Category, fmtstr, ...) \
+ do \
+ { \
+ using namespace std::literals; \
+ Category.Logger().warn(fmtstr##sv, ##__VA_ARGS__); \
+ } while (false)
+
+#define ZEN_LOG_ERROR(Category, fmtstr, ...) \
+ do \
+ { \
+ using namespace std::literals; \
+ Category.Logger().error(fmtstr##sv, ##__VA_ARGS__); \
+ } while (false)
+
+#define ZEN_LOG_CRITICAL(Category, fmtstr, ...) \
+ do \
+ { \
+ using namespace std::literals; \
+ Category.Logger().critical(fmtstr##sv, ##__VA_ARGS__); \
+ } while (false)
+
// Helper macros for logging
#define ZEN_TRACE(fmtstr, ...) \