Log
查看 Markdown线程安全的日志系统,同时写入文件和内存缓存。
include/XBase/Log.h · XBase::Log
void Init(const char* filePath = nullptr); // 默认 <游戏根目录>\XBase\debug.log
void InitForMod(const char* modName); // 默认 <游戏根目录>\XBase\Mods\<模组名>\debug.log
void Shutdown();
bool IsInitialized();
void Write(Level level, const char* message);
void Write(Level level, const std::string& message);
void Info(const char* message);
void Warn(const char* message);
void Error(const char* message);
void Debug(const char* message);
void Info(const std::string& message);
void Warn(const std::string& message);
void Error(const std::string& message);
void Debug(const std::string& message);
std::vector<Entry> GetEntries(); // 最近 600 条
std::size_t GetTotalCount();
std::string GetText(); // 完整文本
std::string GetLogFilePath();Level 枚举: Debug, Info, Warn, ErrorEntry 结构: Level level, std::string message, std::chrono::system_clock::time_point timestamp[YYYY-MM-DD HH:MM:SS] [LEVEL] message 格式日志。不再有 logs 子目录,也不按 asi 位置分家:
XBase::Log::InitForMod("XMenu"); // <游戏根目录>\XBase\Mods\XMenu\debug.logLog::Init() 写 XBase 自身日志 <游戏根目录>\XBase\debug.logInitForMod(),模组名与 asi 文件名一致<游戏根目录>\XBase\XBase.exe,它会列出 XBase 自身与 Mods\ 下每个模组的配置与日志
评论