#pragma once #include #include #include "spdlog/spdlog.h" namespace dynasty { namespace log { class Logger { private: static std::shared_ptr logger_instance_; static std::mutex mutex_; Logger(); public: static std::shared_ptr GetLogger(); static void printStack(void); }; template void log_error(Args &&...args) { SPDLOG_LOGGER_ERROR(Logger::GetLogger(), std::forward(args)...); } template void log_debug(Args &&...args) { SPDLOG_LOGGER_DEBUG(Logger::GetLogger(), std::forward(args)...); } template void log_info(Args &&...args) { SPDLOG_LOGGER_INFO(Logger::GetLogger(), std::forward(args)...); } } //namespace dynasty } // namespace log // Check condition: if not satisifed, exit #define ENFORCE(condition, ...) \ if (!(condition)) { \ dynasty::log::log_error(__VA_ARGS__); \ exit(-1); \ }