X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=store.py;h=67e8a8fad7f9ce3698095914351eb4602fe7564d;hb=e6015816224f8f405e9b1c9557f22e73b21246e8;hp=b3ada4567e38a28613efd0159dafd33ece105a0d;hpb=0c6eb1640c0d0c0e7b679d1702415a35319863f1;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/store.py b/store.py index b3ada45..67e8a8f 100644 --- a/store.py +++ b/store.py @@ -176,15 +176,28 @@ class ReportStore: }) def log_http_request(self, method, url, body, headers, response): - self.add_log({ - "type": "http_request", - "method": method, - "url": url, - "body": body, - "headers": headers, - "status": response.status_code, - "response": response.text - }) + if isinstance(response, Exception): + self.add_log({ + "type": "http_request", + "method": method, + "url": url, + "body": body, + "headers": headers, + "status": -1, + "response": None, + "error": response.__class__.__name__, + "error_message": str(response), + }) + else: + self.add_log({ + "type": "http_request", + "method": method, + "url": url, + "body": body, + "headers": headers, + "status": response.status_code, + "response": response.text + }) def log_error(self, action, message=None, exception=None): self.print_log("[Error] {}".format(action)) @@ -209,6 +222,15 @@ class ReportStore: "action": action, }) + def log_market(self, args, user_id, market_id): + self.add_log({ + "type": "market", + "commit": "$Format:%H$", + "args": vars(args), + "user_id": user_id, + "market_id": market_id, + }) + class BalanceStore: def __init__(self, market): self.market = market