#pragma once #include #include #include #include #include namespace aurora { void log_internal(AuroraLogLevel level, const char* module, const char* message, unsigned int len) noexcept; struct Module { const char* name; explicit Module(const char* name) noexcept : name(name) {} template void report(const AuroraLogLevel level, fmt::format_string fmt, T&&... args) noexcept { auto message = fmt::format(fmt, std::forward(args)...); log_internal(level, name, message.c_str(), message.size()); } template void debug(fmt::format_string fmt, T&&... args) noexcept { report(LOG_DEBUG, fmt, std::forward(args)...); } template void info(fmt::format_string fmt, T&&... args) noexcept { report(LOG_INFO, fmt, std::forward(args)...); } template void warn(fmt::format_string fmt, T&&... args) noexcept { report(LOG_WARNING, fmt, std::forward(args)...); } template void error(fmt::format_string fmt, T&&... args) noexcept { report(LOG_ERROR, fmt, std::forward(args)...); } template [[noreturn]] void fatal(fmt::format_string fmt, T&&... args) noexcept { report(LOG_FATAL, fmt, std::forward(args)...); std::abort(); } }; } // namespace aurora template <> struct fmt::formatter : formatter { auto format(AuroraLogLevel level, format_context& ctx) const -> format_context::iterator; };