diff --git a/log_outgoing_requests/handlers.py b/log_outgoing_requests/handlers.py index aea733a..25cf640 100644 --- a/log_outgoing_requests/handlers.py +++ b/log_outgoing_requests/handlers.py @@ -92,18 +92,21 @@ def emit(self, record: AnyLogRecord): "url": request.url if request else "(unknown)", "hostname": parsed_url.netloc if parsed_url else "(unknown)", "params": parsed_url.params if parsed_url else "(unknown)", - "status_code": response.status_code if response is not None else None, + "status_code": response.status_code if response is not None else None, "method": request.method if request else "(unknown)", "timestamp": timestamp, - "response_ms": int(response.elapsed.total_seconds() * 1000) - if response is not None - else 0, + "response_ms": ( + int(response.elapsed.total_seconds() * 1000) + if response is not None + else 0 + ), "req_headers": self.format_headers(scrubbed_req_headers), - "res_headers": self.format_headers(response.headers if response is not None else {}), + "res_headers": self.format_headers( + response.headers if response is not None else {} + ), "trace": "\n".join(format_exception(exception)) if exception else "", } - if config.save_body_enabled: # check request if ( diff --git a/log_outgoing_requests/utils.py b/log_outgoing_requests/utils.py index be00f5b..6663613 100644 --- a/log_outgoing_requests/utils.py +++ b/log_outgoing_requests/utils.py @@ -113,9 +113,9 @@ def check_content_type(content_type: str) -> bool: For patterns containing a wildcard ("text/*"), check if `content_type.pattern` is a substring of any pattern contained in the list. """ - allowed_content_types: Iterable[ - ContentType - ] = settings.LOG_OUTGOING_REQUESTS_CONTENT_TYPES + allowed_content_types: Iterable[ContentType] = ( + settings.LOG_OUTGOING_REQUESTS_CONTENT_TYPES + ) regular_patterns = [ item.pattern for item in allowed_content_types if not item.pattern.endswith("*") ] @@ -133,9 +133,9 @@ def get_default_encoding(content_type_pattern: str) -> str: """ Get the default encoding for the `ContentType` with the associated pattern. """ - allowed_content_types: Iterable[ - ContentType - ] = settings.LOG_OUTGOING_REQUESTS_CONTENT_TYPES + allowed_content_types: Iterable[ContentType] = ( + settings.LOG_OUTGOING_REQUESTS_CONTENT_TYPES + ) regular_types = [ item for item in allowed_content_types if not item.pattern.endswith("*")