Thanks to visit codestin.com
Credit goes to lib.rs

4 releases

0.0.3 Oct 31, 2024
0.0.2 Oct 31, 2024
0.0.1 Oct 31, 2024
0.0.0 Oct 31, 2024

#693 in Debugging

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

832 downloads per month

MIT/Apache

9KB
64 lines

tracing-print

Crates.io Version docs.rs CI

A simple println-like format for tracing-subscriber.

Prints the message field of an event and no others. Formats the message according to log level:

  • ERROR: red
  • WARN: yellow
  • INFO: no formatting
  • DEBUG: blue
  • TRACE: dim

Usage

let layer = tracing_subscriber::fmt::layer()
    .event_format(tracing_print::Print::default());

Example

Run this example: cargo run --example simple

tracing::error!("error");
tracing::warn!("warn");
tracing::info!("info");
tracing::debug!("debug");
tracing::trace!("trace");

// Functions as a newline
tracing::info!("");

// Other keys than message won't be displayed
tracing::info!(key = "unseen", "only message will be seen");

// Format macros work like normal
tracing::info!(
    "newlines and formatting work\nsee? display={}, debug={:#?}",
    1337,
    Dummy::default()
);

// Extra ANSI colors can also be applied
tracing::info!(
    "{} {} {}",
    "extra".bold(),
    "ansi".underline(),
    "formatting".italic()
);
tracing::error!("{}", "applies before level".underline())

Looks like this:

error
warn
info
debug
trace

only message will be seen
newlines and formatting work
see? display=1337, debug=Dummy {
    _field: (),
}
extra ansi formatting
applies before level

Dependencies

~1.5MB
~27K SLoC