🔇(backend) silence expected 401 warnings on /me

On a busy morning, `/me` alone produced 72k warning logs — 97% of
all warnings. They all come from anonymous requests to `/me`
without credentials, which is normal: `/me` is how the app
determines the current auth status.

These warnings carry no diagnostic value on this endpoint, so
silence them there to cut down on log volume.
This commit is contained in:
lebaudantoine
2026-09-08 12:45:54 +02:00
parent bf76ab1ddf
commit 393d4dbb67
3 changed files with 31 additions and 0 deletions
+4
View File
@@ -12,6 +12,10 @@ and this project adheres to
- 🔒️(backend) enforce display name setting on rename API
### Changed
- 🔇(backend) silence expected 401 warnings on /me
## [1.31.0] - 2026-09-08
### Added
+21
View File
@@ -0,0 +1,21 @@
"""Logging filters for the core application."""
import logging
class SilenceExpected401(logging.Filter):
"""Drop the expected 401 from anonymous hits on the /me endpoint.
The frontend probes `/users/me/` to check authentication; a 401 for
anonymous users is normal, not a warning worth logging.
"""
def filter(self, record):
"""Return False for a 401 on `/users/me`."""
if getattr(record, "status_code", None) == 401:
request = getattr(record, "request", None)
path = getattr(request, "path", "") or ""
if path.rstrip("/").endswith("/users/me"):
return False
return True
+6
View File
@@ -1122,10 +1122,16 @@ class Base(Configuration):
"style": "{",
},
},
"filters": {
"silence_expected_401": {
"()": "core.logging_filters.SilenceExpected401",
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "simple",
"filters": ["silence_expected_401"],
},
},
# Override root logger to send it to console