// mcpp.log — file-based debug logger with verbose terminal output. // // Usage: // mcpp::log::init(cfg); // call once at startup // mcpp::log::debug("tag", "msg"); // writes to ~/.mcpp/log/mcpp.log // mcpp::log::verbose("tag", "msg"); // file + stderr (when --verbose) // // Configuration (priority order): // 1. MCPP_LOG_LEVEL env var: "debug" | "info" | "warn" | "error" | "off" // 2. config.toml [log].level // 3. Default: "off" // // Log file: /mcpp.log (rotated at max_file_size, keeps max_files) module; #include #include export module mcpp.log; import std; export namespace mcpp::log { enum class Level { off, error, warn, info, debug }; struct Config { Level level = Level::off; std::size_t maxFileSize = 10 * 1024 * 1024; // 10MB int maxFiles = 3; std::filesystem::path logDir; }; void init(const Config& cfg); void debug(std::string_view tag, std::string_view message); void info (std::string_view tag, std::string_view message); void warn (std::string_view tag, std::string_view message); void error(std::string_view tag, std::string_view message); // verbose: writes to file (level >= info) AND stderr (when --verbose). void set_verbose(bool v); bool is_verbose(); void verbose(std::string_view tag, std::string_view message); // Scoped verbose timer for diagnosing slow steps (e.g. first-run init / bootstrap // hangs). Logs "