]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - store.py
Merge branch 'dev'
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / store.py
index 2b5c18a1a1a65eb241af2677d322195a5202d18d..67e8a8fad7f9ce3698095914351eb4602fe7564d 100644 (file)
--- 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,15 +222,13 @@ class ReportStore:
             "action": action,
             })
 
-    def log_market(self, args, user_id, market_id, report_path, debug):
+    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,
-            "report_path": report_path,
-            "debug": debug,
             })
 
 class BalanceStore: