Skip to content

Commit

Permalink
Change log level for "/health" endpoint to debug (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel authored Oct 10, 2023
1 parent b6478fa commit b83661c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/352.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set log level for `/health` endpoint to `DEBUG`.
11 changes: 10 additions & 1 deletion sygnal/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,18 @@ def log(self, request: server.Request) -> None:
"""Log this request. Called by request.finish."""
# this also works around a bug in twisted.web.http.HTTPFactory which uses a
# monotonic time as an epoch time.

def _should_log_request() -> bool:
"""Whether we should log at INFO that we processed the request."""
if request.path == b"/health":
return False

return True

log_level = logging.INFO if _should_log_request() else logging.DEBUG
log_date_time = datetimeToLogString()
line = self.log_formatter(log_date_time, request)
self.logger.info("Handled request: %s", line)
self.logger.log(log_level, "Handled request: %s", line)


class PushGatewayApiServer(object):
Expand Down

0 comments on commit b83661c

Please sign in to comment.