simple look

This commit is contained in:
Para Dox
2025-04-27 23:20:19 +07:00
parent 0a6c5e9fb5
commit 191fd11d93

View File

@@ -71,16 +71,19 @@ def proxy():
response = requests.post(TARGET_URL_HTTP, json=incoming) response = requests.post(TARGET_URL_HTTP, json=incoming)
outgoing = response.json() outgoing = response.json()
log_lines = [request_log] # Initialize log_lines here, decide what to include based on error status
log_lines = []
if 'error' in outgoing: if 'error' in outgoing:
# For errors, log both request and response
log_lines.append(request_log)
response_log = f"<== Response (Error):\n{json.dumps(outgoing, indent=2)}" response_log = f"<== Response (Error):\n{json.dumps(outgoing, indent=2)}"
log_lines.append(response_log) log_lines.append(response_log)
# Track the method name if an error occurred and method exists in request # Track the method name if an error occurred and method exists in request
if isinstance(incoming, dict) and 'method' in incoming: if isinstance(incoming, dict) and 'method' in incoming:
error_methods.add(incoming['method']) error_methods.add(incoming['method'])
else: else:
# Log only the method name for successful responses # For success, log only the success message with the method name
method_name = "unknown_method" # Default if not found method_name = "unknown_method" # Default if not found
if isinstance(incoming, dict) and 'method' in incoming: if isinstance(incoming, dict) and 'method' in incoming:
method_name = incoming['method'] method_name = incoming['method']