})
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))
"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: