#ifndef INCLUDE_GUARD_7F6A882F_D897_4355_86DB_CA9487CA4FB2 #define INCLUDE_GUARD_7F6A882F_D897_4355_86DB_CA9487CA4FB2 #include #include #include namespace Utils { // Set true if you want to debug CPU. constexpr bool LOG_INSTRUCTION = false; enum class LogLevel { TRACE, DEBUG, INFO, WARN, // ERROR, CRITICAL, OFF }; void core_dump(); [[noreturn]] void unimplemented(const std::string what, const std::source_location loc = std::source_location::current()); void init_logger(); void set_log_file(std::string filepath); void set_log_level(LogLevel level); template inline void debug(fmt::format_string fmt, Args &&...args) { spdlog::debug(fmt, std::forward(args)...); } template inline void critical(fmt::format_string fmt, Args &&...args) { spdlog::critical(fmt, std::forward(args)...); } template inline void trace(fmt::format_string fmt, Args &&...args) { spdlog::trace(fmt, std::forward(args)...); } template inline void info(fmt::format_string fmt, Args &&...args) { spdlog::info(fmt, std::forward(args)...); } template inline void warn(fmt::format_string fmt, Args &&...args) { spdlog::warn(fmt, std::forward(args)...); } template [[noreturn]] inline void abort(fmt::format_string fmt, Args &&...args) { spdlog::critical(fmt, std::forward(args)...); spdlog::dump_backtrace(); core_dump(); exit(-1); } template inline void instruction_trace(fmt::format_string fmt, Args &&...args) { if constexpr (LOG_INSTRUCTION) Utils::trace(fmt, std::forward(args)...); } } // namespace Utils #endif // INCLUDE_GUARD_7F6A882F_D897_4355_86DB_CA9487CA4FB2