diff options
Diffstat (limited to 'store.py')
-rw-r--r-- | store.py | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -176,15 +176,28 @@ class ReportStore: | |||
176 | }) | 176 | }) |
177 | 177 | ||
178 | def log_http_request(self, method, url, body, headers, response): | 178 | def log_http_request(self, method, url, body, headers, response): |
179 | self.add_log({ | 179 | if isinstance(response, Exception): |
180 | "type": "http_request", | 180 | self.add_log({ |
181 | "method": method, | 181 | "type": "http_request", |
182 | "url": url, | 182 | "method": method, |
183 | "body": body, | 183 | "url": url, |
184 | "headers": headers, | 184 | "body": body, |
185 | "status": response.status_code, | 185 | "headers": headers, |
186 | "response": response.text | 186 | "status": -1, |
187 | }) | 187 | "response": None, |
188 | "error": response.__class__.__name__, | ||
189 | "error_message": str(response), | ||
190 | }) | ||
191 | else: | ||
192 | self.add_log({ | ||
193 | "type": "http_request", | ||
194 | "method": method, | ||
195 | "url": url, | ||
196 | "body": body, | ||
197 | "headers": headers, | ||
198 | "status": response.status_code, | ||
199 | "response": response.text | ||
200 | }) | ||
188 | 201 | ||
189 | def log_error(self, action, message=None, exception=None): | 202 | def log_error(self, action, message=None, exception=None): |
190 | self.print_log("[Error] {}".format(action)) | 203 | self.print_log("[Error] {}".format(action)) |