docs: README Logs section and --log-config flag (#27)

This commit is contained in:
Jeff Smith 2026-04-19 11:37:27 -06:00
parent a61fa8289e
commit 41ee888d3b

View file

@ -37,11 +37,32 @@ The SQLite file lives at `./quartermaster.db` by default. Override with the
## Run ## Run
```sh ```sh
uv run uvicorn quartermaster.main:app --reload uv run uvicorn quartermaster.main:app \
--log-config src/quartermaster/logconfig.json \
--reload
``` ```
Open http://127.0.0.1:8000. Open http://127.0.0.1:8000.
## Logs
Logs are JSON on stdout. Each line has `level` and `event` as queryable
Loki labels (indexed by Promtail on the deploy host), plus arbitrary
extra fields in the JSON body.
Example LogQL queries in Grafana Explore (Loki data source):
```
{container="quartermaster"} | json
{container="quartermaster", event="http_request", status=~"5.."}
{container="quartermaster", event="month_closed"} | json | line_format "{{.path}} {{.message}}"
```
HTTP access logs appear as `event="http_request"` with `method`, `path`,
`status`, and `client_ip` extras. Application events (`month_created`,
`month_closed`, `template_entry_updated`, `posting_added`,
`posting_deleted`) fire at the matching mutation sites.
## Tests ## Tests
```sh ```sh