// 写日志到文件(简单版)
void writeLog(const std::string& msg)
{
// 1. 获取当前时间
time_t now = time(0);
char timeBuf[20];
tm localTime;
localtime_s(&localTime, &now); // Windows 安全版
strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S", &localTime);
// 2. 打开日志文件(追加模式)
std::ofstream ofs("config.log", std::ios::app);
// 3. 写入:时间 + 消息
ofs << "[" << timeBuf << "] " << msg << std::endl;
}