feat: Migrate to flagsmith-common centralized logging#7050
feat: Migrate to flagsmith-common centralized logging#7050
Conversation
- Replace LOGGING dict with no-op (setup_logging runs before Django) - Remove structlog.configure block (handled by flagsmith-common) - Remove util/logging.py (JsonFormatter, GunicornJsonCapableLogger now in flagsmith-common) - Remove GUNICORN_LOGGER_CLASS from .env-ci (default in flagsmith-common) - Remove PROMETHEUS_HISTOGRAM_BUCKETS setting (uses library defaults) - Pin flagsmith-common to feat/logging-improvements branch
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7050 +/- ##
=======================================
Coverage 98.33% 98.33%
=======================================
Files 1337 1335 -2
Lines 50010 49941 -69
=======================================
- Hits 49178 49111 -67
+ Misses 832 830 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.
Once credits are available, reopen this pull request to trigger a review.
Docker builds report
|
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
|
docs/if required so people know about the feature.Changes
Contributes to Flagsmith/flagsmith-common#179
Will be ready for merge once Flagsmith/flagsmith-common#179 is merged and released.
Migrates logging setup from Django settings to flagsmith-common's
setup_logging(), which runs before Django loads.LOGGING_CONFIG = Noneto prevent Django from wipingsetup_logging()configurationstructlog.configureblock (handled by flagsmith-common)util/logging.py(JsonFormatter,GunicornJsonCapableLoggernow in flagsmith-common)GUNICORN_LOGGER_CLASSfrom.env-ci(default in flagsmith-common)PROMETHEUS_HISTOGRAM_BUCKETSsetting (uses library defaults)feat/logging-improvementsbranchEnv vars to set
How did you test this code?
Tested with
ghcr.io/flagsmith/flagsmith-api:pr-7050.Generic format (
LOG_FORMAT=generic):ConsoleRendererwith ISO timestamps, no ANSI in non-TTYJSON format (
LOG_FORMAT=json):Boot logs:
{"timestamp": "2026-03-26T17:36:45.855679Z", "message": "Starting gunicorn 23.0.0", "levelname": "INFO", "logger_name": "gunicorn.error", "pid": 1, "thread_name": "MainThread"}Access log (structured):
{"timestamp": "2026-03-26T17:36:54.266879Z", "time": "2026-03-26T17:36:54+00:00", "path": "/health/liveness/", "remote_ip": "192.168.215.1", "method": "GET", "status": "400", "user_agent": "curl/8.7.1", "duration_in_ms": 14, "response_size_in_bytes": 143, "message": "192.168.215.1 - - [26/Mar/2026:17:36:54 +0000] \"GET /health/liveness/ HTTP/1.1\" 400 143 \"-\" \"curl/8.7.1\" - -", "levelname": "INFO", "logger_name": "gunicorn.access", "pid": 7, "thread_name": "ThreadPoolExecutor-3_0"}Django error log (also structured):
{"exc_info": ["<class 'django.core.exceptions.DisallowedHost'>", "..."], "timestamp": "2026-03-26T17:36:54.265623Z", "status_code": 400, "message": "Invalid HTTP_HOST header: '127.0.0.1:8001'...", "levelname": "ERROR", "logger_name": "django.security.DisallowedHost", "pid": 7, "thread_name": "ThreadPoolExecutor-3_0"}