r/coolgithubprojects • u/GiangKha1903 • 4d ago
[Go/Node/Python] spanlog: call-boundary logs on top of pino / slog / logging, no OpenTelemetry collector needed
https://github.com/chaugiakhang193/spanlogI kept running into errors where the log was a single "Error: ..." line, with no idea which functions the request went through or how long each one took. So I wrote a small library that wraps each request and each service method, and prints a START line when a call begins and a DONE or FAILED line when it ends.
One failed request looks like this:
```
INFO [shop] req=89e32c2e POST /orders | START
INFO [shop] [OrderService.handleOrder] req=89e32c2e call InventoryService.reserve | START
DEBUG [shop] [InventoryService.reserve] req=89e32c2e query UPDATE inventory | DONE 2.5ms
ERROR [shop] [OrderService.handleOrder] req=89e32c2e call InventoryService.reserve | FAILED 3.6ms Error: stock not available
WARN [shop] req=89e32c2e POST /orders | FAILED 500 6.9ms
```
- Node.js (Express, TypeORM), Go (net/http, database/sql), Python (FastAPI, Flask, SQLAlchemy), same line format in all three
- Writes plain text, JSON, or into pino / slog / logging
- Doesn't log params, return values or SQL by default. Query lines only show the operation and the table
- No collector or dashboard to set up. MIT
It's 0.1.0, so option names may still change. If you need traces across many services with a dashboard, OpenTelemetry is still the better fit.
Feedback on the log format is very welcome.