Skip to content

Commit

Permalink
fixup! [2/2] Fix: Log request body (#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
achave11-ucsc committed Oct 31, 2024
1 parent b9f329a commit 730d487
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/azul/chalice.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,15 @@ def _log_request(self):

body = self.current_request.json_body
if body is None:
body_len_msg = ''
len_msg = ''
elif config.debug == 2:
body = json.dumps(body, cls=self._LogJSONEncoder)
body_len_msg = f' ({len(body)} characters)'
len_msg = f' ({len(body)} characters)'
else:
n = 1024
body_len_msg = f' (first {str(n)} characters)'
len_msg = f' (first {str(n)} characters)'
body = json_head(n, body) if not isinstance(body, str | bytes) else body[:n]
log.info('%s%s',
http_body_log_message('request', body, verbatim=True), body_len_msg)
log.info('%s', http_body_log_message('request', body, verbatim=True) + len_msg)

def _log_response(self, response):
if log.isEnabledFor(logging.DEBUG):
Expand Down

0 comments on commit 730d487

Please sign in to comment.