From 191fd11d93993d0fdfca0457acfcf8bba05c97eb Mon Sep 17 00:00:00 2001 From: Para Dox Date: Sun, 27 Apr 2025 23:20:19 +0700 Subject: [PATCH] simple look --- logging-proxy/proxy.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/logging-proxy/proxy.py b/logging-proxy/proxy.py index 93893c10..3235dd41 100644 --- a/logging-proxy/proxy.py +++ b/logging-proxy/proxy.py @@ -71,16 +71,19 @@ def proxy(): response = requests.post(TARGET_URL_HTTP, json=incoming) 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: + # For errors, log both request and response + log_lines.append(request_log) response_log = f"<== Response (Error):\n{json.dumps(outgoing, indent=2)}" log_lines.append(response_log) # Track the method name if an error occurred and method exists in request if isinstance(incoming, dict) and 'method' in incoming: error_methods.add(incoming['method']) 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 if isinstance(incoming, dict) and 'method' in incoming: method_name = incoming['method']