MCPcopy Create free account
hub / github.com/HisMax/RedInk / log_request

Function log_request

backend/routes/utils.py:17–40  ·  view source on GitHub ↗

记录 API 请求日志 Args: endpoint: API 端点路径 data: 请求数据(会过滤敏感信息)

(endpoint: str, data: dict = None)

Source from the content-addressed store, hash-verified

15
16
17def log_request(endpoint: str, data: dict = None):
18 """
19 记录 API 请求日志
20
21 Args:
22 endpoint: API 端点路径
23 data: 请求数据(会过滤敏感信息)
24 """
25 logger.info(f"📥 收到请求: {endpoint}")
26
27 if data:
28 # 过滤敏感信息和大数据(图片二进制)
29 safe_data = {
30 k: v for k, v in data.items()
31 if k not in ['images', 'user_images'] and not isinstance(v, bytes)
32 }
33
34 # 对图片数据只显示数量
35 if 'images' in data:
36 safe_data['images'] = f"[{len(data['images'])} 张图片]"
37 if 'user_images' in data:
38 safe_data['user_images'] = f"[{len(data['user_images'])} 张图片]"
39
40 logger.debug(f" 请求数据: {safe_data}")
41
42
43def log_error(endpoint: str, error: Exception):

Callers 6

generate_imagesFunction · 0.85
retry_single_imageFunction · 0.85
retry_failed_imagesFunction · 0.85
regenerate_imageFunction · 0.85
generate_contentFunction · 0.85
generate_outlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected