docs: README Logs section and --log-config flag (#27)
This commit is contained in:
parent
a61fa8289e
commit
41ee888d3b
1 changed files with 22 additions and 1 deletions
23
README.md
23
README.md
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue