/** * @file logger.hpp * @brief Structured logging using modern C++23 std::format. */ #pragma once #include #include #include #include #include namespace app::utils { enum class LogLevel { Debug, Info, Warn, Error }; class Logger { public: explicit Logger(std::string name) : name_(std::move(name)) {} template void info(std::format_string fmt, Args&&... args, std::source_location loc = std::source_location::current()) { log(LogLevel::Info, std::format(fmt, std::forward(args)...), loc); } template void error(std::format_string fmt, Args&&... args, std::source_location loc = std::source_location::current()) { log(LogLevel::Error, std::format(fmt, std::forward(args)...), loc); } template void debug(std::format_string fmt, Args&&... args, std::source_location loc = std::source_location::current()) { log(LogLevel::Debug, std::format(fmt, std::forward(args)...), loc); } private: void log(LogLevel level, const std::string& message, const std::source_location& loc); std::string name_; }; Logger& get_logger(const std::string& name); } // namespace app::utils