From 90d7423eec074a0ed0af680c223180f8d7e1d4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 4 Apr 2018 12:02:13 +0200 Subject: Add logging at market instance creation --- store.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'store.py') diff --git a/store.py b/store.py index b3ada45..2b5c18a 100644 --- a/store.py +++ b/store.py @@ -209,6 +209,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 -- cgit v1.2.3 From d8e233ac11edac1481f0315e25f79b0390c45e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 4 Apr 2018 12:02:50 +0200 Subject: Log http requests exceptions --- store.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'store.py') diff --git a/store.py b/store.py index 2b5c18a..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)) -- cgit v1.2.3