devlog-tracing

Crates.iodevlog-tracing
lib.rsdevlog-tracing
version0.1.1
sourcesrc
created_at2024-09-28 21:18:48.468773
updated_at2024-10-02 17:04:32.186701
descriptionLog subscriber for the tracing library, with a human-readable output format designed for development builds.
homepagehttps://hermannm.dev/devlog
repositoryhttps://github.com/hermannm/devlog-tracing
max_upload_size
id1390378
size27,231
(hermannm)

documentation

README

devlog-tracing

Log subscriber for Rust's tracing library, with a human-readable output format designed for development builds. Uses the same format as the devlog library for Go.

Run cargo add devlog-tracing to add it to your project!

Usage

devlog-tracing is pretty much a drop-in replacement for tracing-subscriber, so the initialization works the same - just replace tracing_subscriber::fmt() with devlog_tracing::subscriber():

devlog_tracing::subscriber().init();

tracing logs will now be formatted by the devlog-tracing subscriber:

// In module `app::server`
warn!("No value found for 'PORT' in env, defaulting to 8000");
info!(port = 8000, environment = "DEV", "Server started");

// In module `app::db`
error!(cause = "UNKNOWN_TABLE", "Database query failed");

...giving the following output (using a gruvbox terminal color scheme):

Screenshot of log messages in a terminal

Commit count: 23

cargo fmt