Structured JSON logging from tracing with fields from spans
Unlike the JSON support in tracing_subscriber, this implementation treats spans as a way to provide context and adds all fields from all spans to the logged events.
Examples
use ;
use *;
use JsonLayer;
registry.with.init;
let _span = info_span!.entered;
info!;
Will produce the following output
Customising timestamps
use format_description;
use ;
use *;
use JsonLayer;
let timestamp_format = format_description!;
registry.with.init;
let _span = info_span!.entered;
error!;
Will produce the following output
Thanks
See also
- https://github.com/vertexclique/tracing-json is a very similar crate, but lacking documentation
- https://docs.rs/traceon/ is another alternative