From 457149dfac7c570f673b97dd798a743159888d89 Mon Sep 17 00:00:00 2001 From: hashjang Date: Fri, 16 May 2025 10:13:24 +0800 Subject: [PATCH] feat: add debug log for request and response (#19781) -- run reformat --- api/extensions/ext_logging.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/api/extensions/ext_logging.py b/api/extensions/ext_logging.py index 67238c562c..410ca7aed9 100644 --- a/api/extensions/ext_logging.py +++ b/api/extensions/ext_logging.py @@ -76,14 +76,12 @@ def init_app(app: DifyApp): "Received Request %s -> %s, Request Body:\n%s", flask.request.method, flask.request.path, - formatted_json + formatted_json, ) except Exception: logging.exception("Failed to parse JSON request") else: - logging.debug("Received Request %s -> %s", - flask.request.method, - flask.request.path) + logging.debug("Received Request %s -> %s", flask.request.method, flask.request.path) # for debugging purposes, log the response @app.after_request @@ -97,18 +95,13 @@ def init_app(app: DifyApp): json_data = json.loads(response_data) formatted_json = json.dumps(json_data, ensure_ascii=False, indent=2) logging.debug( - "Response %s %s, Response Body:\n%s", - response.status, - response.content_type, - formatted_json + "Response %s %s, Response Body:\n%s", response.status, response.content_type, formatted_json ) except Exception: logging.exception("Failed to parse JSON response") else: - logging.debug("Response %s %s", - response.status, - response.content_type) - + logging.debug("Response %s %s", response.status, response.content_type) + return response