debug: add request logging to APIClient

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wangdl 2026-06-19 12:14:10 +08:00
parent 4dea11a48b
commit 78d2c93b41
2 changed files with 6 additions and 1 deletions

View File

@ -56,10 +56,15 @@ actor APIClient {
} }
if let body { if let body {
request.httpBody = try JSONEncoder().encode(AnyEncodable(body)) let encoded = try JSONEncoder().encode(AnyEncodable(body))
request.httpBody = encoded
print("[APIClient] \(method) \(path) bodySize=\(encoded.count)")
} else {
print("[APIClient] \(method) \(path)")
} }
let (data, response) = try await session.data(for: request) let (data, response) = try await session.data(for: request)
print("[APIClient] \(method) \(path) -> response received")
guard let httpResponse = response as? HTTPURLResponse else { guard let httpResponse = response as? HTTPURLResponse else {
throw APIError.networkError(NSError(domain: "", code: -1)) throw APIError.networkError(NSError(domain: "", code: -1))