Add verbose request logging feature to wallet (#758)

* Add verbose request logging feature to wallet

* add verbose cli tests

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
Olindo Task
2025-06-24 14:31:40 -06:00
committed by GitHub
parent 48823d673d
commit bbfb63b34e
5 changed files with 78 additions and 2 deletions

View File

@@ -188,7 +188,26 @@ class LedgerAPI(LedgerAPIDeprecated, SupportsAuth):
}
)
return await self.httpx.request(method, path, **kwargs)
# Verbose logging of requests when enabled
if settings.wallet_verbose_requests:
request_info = f"{method} {self.url.rstrip('/')}/{path}"
if "json" in kwargs:
request_info += f"\nPayload: {json.dumps(kwargs['json'], indent=2)}"
print(f"Request: {request_info}")
resp = await self.httpx.request(method, path, **kwargs)
# Verbose logging of responses when enabled
if settings.wallet_verbose_requests:
response_info = f"Response: {resp.status_code}"
try:
json_response = resp.json()
response_info += f"\n{json.dumps(json_response, indent=2)}"
except json.JSONDecodeError:
response_info += f"\n{resp.text}"
print(response_info)
return resp
"""
ENDPOINTS