From b0d719451bb0416658aabd1e27f98ba3109bdbe3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zayakin Date: Tue, 15 Apr 2025 12:26:35 +0300 Subject: [PATCH] [#373] Add step to httpClient for log write Signed-off-by: Dmitriy Zayakin --- src/frostfs_testlib/clients/http/http_client.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/frostfs_testlib/clients/http/http_client.py b/src/frostfs_testlib/clients/http/http_client.py index aebd5ef..16d7707 100644 --- a/src/frostfs_testlib/clients/http/http_client.py +++ b/src/frostfs_testlib/clients/http/http_client.py @@ -15,14 +15,14 @@ LOGGING_CONFIG = { "handlers": {"default": {"class": "logging.StreamHandler", "formatter": "http", "stream": "ext://sys.stderr"}}, "formatters": { "http": { - "format": "%(levelname)s [%(asctime)s] %(name)s - %(message)s", + "format": "%(asctime)s [%(levelname)s] %(name)s - %(message)s", "datefmt": "%Y-%m-%d %H:%M:%S", } }, "loggers": { "httpx": { "handlers": ["default"], - "level": "DEBUG", + "level": "ERROR", }, "httpcore": { "handlers": ["default"], @@ -43,7 +43,7 @@ class HttpClient: response = client.request(method, url, **kwargs) self._attach_response(response, **kwargs) - logger.info(f"Response: {response.status_code} => {response.text}") + # logger.info(f"Response: {response.status_code} => {response.text}") if expected_status_code: assert ( @@ -131,6 +131,7 @@ class HttpClient: reporter.attach(report, "Requests Info") reporter.attach(curl_request, "CURL") + cls._write_log(curl_request, response_body, response.status_code) @classmethod def _create_curl_request(cls, url: str, method: str, headers: httpx.Headers, data: str, files: dict) -> str: @@ -143,3 +144,9 @@ class HttpClient: # Option -k means no verify SSL return f"curl {url} -X {method} {headers}{data} -k" + + @classmethod + def _write_log(cls, curl: str, res_body: str, res_code: int) -> None: + if res_body: + curl += f"\nResponse: {res_code}\n{res_body}" + logger.info(f"{curl}") -- 2.45.3