MCPcopy Create free account
hub / github.com/BlueSkyXN/AI2API / saveResponseToFile

Function saveResponseToFile

wo2api.go:2310–2328  ·  view source on GitHub ↗

调试辅助函数 - 保存响应内容到文件

(data []byte, reqID string)

Source from the content-addressed store, hash-verified

2308
2309// 调试辅助函数 - 保存响应内容到文件
2310func saveResponseToFile(data []byte, reqID string) {
2311// 创建logs目录(如果不存在)
2312logDir := "logs"
2313if _, err := os.Stat(logDir); os.IsNotExist(err) {
2314 os.Mkdir(logDir, 0755)
2315}
2316
2317// 创建文件名
2318timestamp := time.Now().Format("20060102_150405")
2319filename := filepath.Join(logDir, fmt.Sprintf("response_%s_%s.txt", timestamp, reqID[:8]))
2320
2321// 写入原始内容
2322if err := os.WriteFile(filename, data, 0644); err != nil {
2323 logError("[reqID:%s] 保存响应到文件失败: %v", reqID, err)
2324 return
2325}
2326
2327logDebug("[reqID:%s] 已保存响应到文件: %s", reqID, filename)
2328}
2329
2330// 保存完整响应内容以便后续分析
2331func saveFullResponseForAnalysis(bodyBytes []byte, reqID string) {

Callers

nothing calls this directly

Calls 2

logErrorFunction · 0.70
logDebugFunction · 0.70

Tested by

no test coverage detected