Add an optional JSON log format shared with uvicorn
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend, observability
Direzione di ricerca
Read CONTRIBUTING.md, then inspect main() in app/app.py and the existing test_main_function_* tests in tests/unit/test_app_unit.py. Trace how uvicorn.run is configured and how logging is currently initialized before defining the shared configuration. Done means both app and uvicorn logs support the documented JSON/text modes, tests cover the listed fields and safety requirements, and README plus .env.example are updated.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔄 Updated for v5.0.0 (2026-10-08). Still open. #208 has since removed the stray
filemodeargument, so the background no longer mentions it. 5.0.0 (#241) logs the whole profile at INFO, now includinggenderanddateOfBirth; that is deliberate, and this issue changes only the format.
Summary
pesu-auth writes plain-text logs, and uvicorn's own logs (access log, startup, errors) use a different format. Plain text is fine on a laptop, but hard to search and filter in a log service: finding "all failed logins for this user in the last hour" means writing regular expressions. Add an optional structured JSON log format, used by both pesu-auth and uvicorn, while keeping today's readable text as the default for local development.
Background
main()inapp/app.pycallslogging.basicConfig(level=..., format=...).uvicorn.run(...)is called withoutlog_config, so uvicorn installs its own default logging config foruvicorn,uvicorn.erroranduvicorn.access.- Usernames and profile data are logged at INFO on purpose, to trace logins (see
docs/security.md). This issue changes how logs are formatted, not what is logged. Passwords and tokens must never appear.
Proposed change
- Setting: a
LOG_FORMATenvironment variable,text(the default) orjson, read once at startup. An unknown value fails startup with a clear message. Document it in.env.exampleand the README. - JSON formatter, using only the standard library (a small
logging.Formattersubclass inapp/logging_config.py), so no new dependency is needed. One JSON object per line, with:timestamp(ISO 8601 with offset),level,logger,message;module,function,line;exc_infoas a string when present;request_idwhen #200 is in.
- One configuration for everything: build a
logging.config.dictConfig-style dict used both by the app and asuvicorn.run(..., log_config=...), so uvicorn's access and error logs use the same format. Keep--debugcontrolling the level. - A maintainer sets
LOG_FORMAT=jsonon the Render services after merge. Mention this in the PR description.
Tests
- The JSON formatter: valid JSON on one line; includes the fields above; exceptions are serialised; non-ASCII usernames are handled.
-
main()passes the same config to uvicorn (patchuvicorn.run, as the existingtest_main_function_*tests intests/unit/test_app_unit.pydo). -
LOG_FORMATacceptstextandjson, and anything else is rejected. - No test output contains a password.
Acceptance criteria
-
LOG_FORMAT=jsonmakes every log line, the app's and uvicorn's, a single JSON object - The default output is readable text, as today
- No new dependency; documented in the README and
.env.example
How to contribute
- Wait until you're assigned. Comment to ask for this issue, then wait for a maintainer to assign it to you before writing any code. PRs for unassigned issues are closed without review.
- Read
CONTRIBUTING.mdfirst. It covers forking, setting up withuv, and running the tests. - Branch from
devin your fork, and open the PR againstdevwith a Conventional Commit title andCloses #201in the description. - Bump the minor version in
pyproject.tomland runuv lock(CI checks this).uv run pre-commit run --all-filesmust pass, and coverage must stay at 100%. - Update the README,
app/docs/and comments in the same PR as the behaviour they describe. - Never log, print, store or echo a password or token, including in tests, PR descriptions and screenshots.
- Lingua principale
- Python
- Stelle
- 22
- Fork
- 29
- Merge medio
- 22h 1m
- PR unite (30g)
- 20
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pesu-dev/auth
-
Check the README for dead links and fix the misleading Docker Hub badgeForse di nuovo libera @knownshah l’ha presa 17 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
pesu-dev/auth#220 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Run the same checks locally and in CI: pre-commit hooks in CI, and hooks that match CIForse già presa @achyu-dev l’ha presa 1 giorno fa. Apertabug tests and ci/cd
pesu-dev/auth#250 · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
I maintainer di solito rispondono entro 1 giorno
-
Commit SHA should be used instead of tag git based deployForse già presa @aditeyabaral l’ha presa 11 giorni fa. Apertabug
pesu-dev/auth#236 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Private Functions in `app.py` needs to be in separate fileForse già presa @aditeyabaral l’ha presa 11 giorni fa. Apertaapi enhancement
pesu-dev/auth#235 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pesu-dev/auth
Issue simili
-
fix formatting of the sample database page of the docsForse già presa @Aaqibhafeezkhan l’ha presa oggi. Apertadocumentation good first issue help wanted
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
chaoss/CollectOSS#544 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area/plugin good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
kestra-io/plugin-soda#137 ·
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
ibm-granite/granite.build#504 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno