Closed
Description
Specification
Structured logging is to use JSON on the STDERR logs. This exposes more of the data, and allows us to create a standard for the set of fields to be used.
There's no real official standard for structured logging. But journalctl and syslog defines some common fields. The fields can be similar to our formatting
that we already use, but this time in a JSON format. Additional data fields can be encoded too.
We could put a json
formatting in somewhere that provides the JSON serialisation.
This can be especially useful since we are also looking into adding error chaining, which we have done in a few places. But by creating our own @matrixai/error
we can implement error chaining. MatrixAI/Polykey#304
Additional context
- Integrate Error Chaining in a js-errors or @matrixai/errors package Polykey#304
- https://www.structlog.org/en/stable/
- https://github.com/uber-go/zap
- Implementing BIP39 recovery, Unattended Bootstrap and Agent Start and Status Polykey#283 (comment) - where an error came up and no context was there, but all in the
data
which required manual serialisation
Tasks
- Research different structured logging libraries
- Compare with opentracing or tracing based data formats
- Implement simple structured logging capabilities into js-logger