#pragma once #include "fmt/core.h" #include "fmt/ranges.h" #include #ifdef USE_SDL1 #include "sdl2_to_1_2_backports.h" #endif namespace devilution { enum class LogCategory { Application = SDL_LOG_CATEGORY_APPLICATION, Error = SDL_LOG_CATEGORY_ERROR, Assert = SDL_LOG_CATEGORY_ASSERT, System = SDL_LOG_CATEGORY_SYSTEM, Audio = SDL_LOG_CATEGORY_AUDIO, Video = SDL_LOG_CATEGORY_VIDEO, Render = SDL_LOG_CATEGORY_RENDER, Input = SDL_LOG_CATEGORY_INPUT, Test = SDL_LOG_CATEGORY_TEST, }; enum class LogPriority { Verbose = SDL_LOG_PRIORITY_VERBOSE, Debug = SDL_LOG_PRIORITY_DEBUG, Info = SDL_LOG_PRIORITY_INFO, Warn = SDL_LOG_PRIORITY_WARN, Error = SDL_LOG_PRIORITY_ERROR, Critical = SDL_LOG_PRIORITY_CRITICAL, }; template void Log(const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_Log("%s", str.c_str()); } template void LogVerbose(LogCategory category, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogVerbose(static_cast(category), "%s", str.c_str()); } template void LogDebug(LogCategory category, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogDebug(static_cast(category), "%s", str.c_str()); } template void LogInfo(LogCategory category, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogInfo(static_cast(category), "%s", str.c_str()); } template void LogWarn(LogCategory category, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogWarn(static_cast(category), "%s", str.c_str()); } template void LogError(LogCategory category, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogError(static_cast(category), "%s", str.c_str()); } template void LogCritical(LogCategory category, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogCritical(static_cast(category), "%s", str.c_str()); } template void LogMessageV(LogCategory category, LogPriority priority, const char *fmt, Args &&... args) { auto str = fmt::format(fmt, std::forward(args)...); SDL_LogMessageV(static_cast(category), static_cast(priority), "%s", str.c_str()); } } // namespace devilution