X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=store.py;h=3f3718f4f8c0bff4e253a0a090e5820bd8065726;hb=d8e233ac11edac1481f0315e25f79b0390c45e29;hp=b3ada4567e38a28613efd0159dafd33ece105a0d;hpb=b4e0ba0b0aa84550d0b06338b59557c3050798c9;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git diff --git a/store.py b/store.py index b3ada45..3f3718f 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,17 @@ class ReportStore: "action": action, }) + def log_market(self, args, user_id, market_id, report_path, debug): + self.add_log({ + "type": "market", + "commit": "$Format:%H$", + "args": vars(args), + "user_id": user_id, + "market_id": market_id, + "report_path": report_path, + "debug": debug, + }) + class BalanceStore: def __init__(self, market): self.market = market