Structured Logs
The
structlog
Concept
When initialized, the logger starts a thread with a record handler. The logger
has a number of methods, each of which creates a record with the corresponding
logging level, e.g.
info()
By chaining method calls, the module user can create a record with any structure.
The final
.send()
The record handler completely defines how to prepare the
Record
RecordHandler
TextHandler
JSONHandler
Usage
import structlog
fn main() {
log := structlog.new()
defer {
log.close()
}
log.info().message('Hello, World!').send()
}
Output:
2026-01-03T09:33:35.366Z [INFO ] message: 'Hello, World!'
See also
examples