Skip to content

Commit

Permalink
Add RPC logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed Jun 25, 2024
1 parent f900032 commit 1254873
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rpc/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import aiohttp
import rapidjson as json
import socket
Expand All @@ -19,6 +20,7 @@ def instance(cls) -> 'RPCClient':
cls.node_url = Config.instance().node_url
cls.session = aiohttp.ClientSession(json_serialize=json.dumps)
cls.bpow_key = os.getenv('BPOW_KEY', None)
cls.logger = logging.getLogger('RPCClient')
return cls._instance

@classmethod
Expand All @@ -30,7 +32,12 @@ async def close(cls):

async def make_request(self, req_json: dict):
async with self.session.post(self.node_url ,json=req_json, timeout=300) as resp:
return await resp.json()
respJson = await resp.json()
if resp.status != 200:
self.logger.error(f"RPC request failed with status {resp.status}")
self.logger.error(f"Request: {req_json}")
self.logger.error(f"Response: {respJson}")
return respJson

async def account_create(self) -> str:
account_create = {
Expand Down

0 comments on commit 1254873

Please sign in to comment.