Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimon committed Nov 16, 2024
1 parent 978c2be commit 5f502a5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions apitally/client/request_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,25 @@ def log_request(self, request: RequestDict, response: ResponseDict) -> None:
response["body"] = None

if request["body"] is not None and self.config.mask_request_body_callback is not None:
request["body"] = self.config.mask_request_body_callback(
request["method"], request["path"] or parsed_url.path, request["body"]
)
try:
request["body"] = self.config.mask_request_body_callback(
request["method"], request["path"] or parsed_url.path, request["body"]
)
except Exception:
logger.exception("User-provided mask_request_body_callback raised an exception")
request["body"] = None

Check warning on line 178 in apitally/client/request_logging.py

View check run for this annotation

Codecov / codecov/patch

apitally/client/request_logging.py#L176-L178

Added lines #L176 - L178 were not covered by tests
if request["body"] is None:
request["body"] = BODY_MASKED
elif len(request["body"]) > MAX_BODY_SIZE:
request["body"] = BODY_TOO_LARGE

Check warning on line 182 in apitally/client/request_logging.py

View check run for this annotation

Codecov / codecov/patch

apitally/client/request_logging.py#L181-L182

Added lines #L181 - L182 were not covered by tests
if response["body"] is not None and self.config.mask_response_body_callback is not None:
response["body"] = self.config.mask_response_body_callback(
request["method"], request["path"] or parsed_url.path, response["body"]
)
try:
response["body"] = self.config.mask_response_body_callback(
request["method"], request["path"] or parsed_url.path, response["body"]
)
except Exception:
logger.exception("User-provided mask_response_body_callback raised an exception")
response["body"] = None

Check warning on line 190 in apitally/client/request_logging.py

View check run for this annotation

Codecov / codecov/patch

apitally/client/request_logging.py#L188-L190

Added lines #L188 - L190 were not covered by tests
if response["body"] is None:
response["body"] = BODY_MASKED
elif len(response["body"]) > MAX_BODY_SIZE:
Expand Down

0 comments on commit 5f502a5

Please sign in to comment.