#pragma once #include #include #include #include // Logger lleuger embolicant `SDL_Log*`. Una sola entrada per nivell, format // type-safe via `std::format`. Filtre runtime amb la variable d'entorn // AEE_LOG (sintaxi `*:info,Resource::Helper:warn,scene:debug`). Ús típic: // // Log::info("Resource::Helper", "pack loaded ({} entries)", n); // Log::warn("Options", "preset \"{}\" no trobat; aplicant defaults.", name); // Log::error("Director", "no s'ha pogut carregar config.yaml a {}", path); // namespace Log { enum class Level : std::uint8_t { TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, }; // Llig AEE_LOG i configura les prioritats SDL. Crida una sola vegada, // tan aviat com sigui possible (abans del primer `Log::*`). void init(); // Backend usat per les funcions per nivell. Composa "tag: msg" i ho // entrega a SDL_LogMessage amb la categoria registrada per al tag. void log(Level lvl, std::string_view tag, std::string_view msg); // Variant sense prefix de tag — ús reservat per a marcadors literals // (p. ex. "Game start" / "Bye!"). Cau a SDL_LOG_CATEGORY_APPLICATION, // així AEE_LOG global encara els pot silenciar. void raw(Level lvl, std::string_view msg); template void trace(std::string_view tag, std::format_string fmt, Args&&... args) { log(Level::TRACE, tag, std::format(fmt, std::forward(args)...)); } template void debug(std::string_view tag, std::format_string fmt, Args&&... args) { log(Level::DEBUG, tag, std::format(fmt, std::forward(args)...)); } template void info(std::string_view tag, std::format_string fmt, Args&&... args) { log(Level::INFO, tag, std::format(fmt, std::forward(args)...)); } template void warn(std::string_view tag, std::format_string fmt, Args&&... args) { log(Level::WARN, tag, std::format(fmt, std::forward(args)...)); } template void error(std::string_view tag, std::format_string fmt, Args&&... args) { log(Level::ERROR, tag, std::format(fmt, std::forward(args)...)); } template void critical(std::string_view tag, std::format_string fmt, Args&&... args) { log(Level::CRITICAL, tag, std::format(fmt, std::forward(args)...)); } } // namespace Log