mirror of
https://github.com/chenyme/grok2api.git
synced 2026-12-05 16:02:12 +00:00
perf: 削减高频 DEBUG 日志噪声
- headers: 移除完整 headers JSON dump, 仅记录 header_count - http: post_json 失败降级为 warning, 移除 body 输出 - chat: 移除逐帧 SSE debug 日志 (chat sse frame / stream adapter skipped)
This commit is contained in:
1 parent
e372d444a6
commit
d5001cbb5f
3 files changed
+2
-6
No files matched your search
@@ -241,8 +241,7 @@ def build_http_headers(
|
||||
headers.update(_client_hints(browser, raw_ua))
|
||||
headers["Cookie"] = build_sso_cookie(cookie_token, lease=lease)
|
||||
|
||||
_log = {k: ("<redacted>" if k == "Cookie" else v) for k, v in headers.items()}
|
||||
logger.debug("http headers built: header_count={} headers_json={}", len(headers), orjson.dumps(_log).decode())
|
||||
logger.debug("http headers built: header_count={}", len(headers))
|
||||
return headers
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ async def post_json(
|
||||
body_bytes = response.content
|
||||
if response.status_code not in (200, 201, 204):
|
||||
body_text = body_bytes.decode("utf-8", "replace")[:400]
|
||||
logger.error("http json post failed: url={} status={} body={}", url, response.status_code, body_text)
|
||||
logger.warning("http json post failed: url={} status={}", url, response.status_code)
|
||||
raise UpstreamError(f"Upstream returned {response.status_code}", status=response.status_code, body=body_text)
|
||||
return orjson.loads(body_bytes) if body_bytes.strip() else {}
|
||||
|
||||
|
||||
@@ -364,14 +364,11 @@ async def completions(
|
||||
timeout_s = timeout_s,
|
||||
):
|
||||
event_type, data = classify_line(line)
|
||||
logger.debug("chat sse frame received: event_type={} data_len={}", event_type, len(data))
|
||||
if event_type == "done":
|
||||
break
|
||||
if event_type != "data" or not data:
|
||||
continue
|
||||
events = adapter.feed(data)
|
||||
if not events:
|
||||
logger.debug("chat stream adapter skipped frame: preview={}", data[:120])
|
||||
for ev in events:
|
||||
if tool_calls_emitted:
|
||||
break # already sent [DONE], drop remaining events
|
||||
|
||||
Reference in new issue
Block a user