mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 10:34:20 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user