6 releases

0.1.5 Jun 3, 2024
0.1.4 Jun 2, 2024

#287 in Debugging

Download history 17/week @ 2024-07-25 35/week @ 2024-08-01 16/week @ 2024-08-08 21/week @ 2024-08-15 1/week @ 2024-08-29 22/week @ 2024-09-05 59/week @ 2024-09-12 36/week @ 2024-09-19 18/week @ 2024-09-26 25/week @ 2024-10-03 4/week @ 2024-10-10 10/week @ 2024-10-17 55/week @ 2024-10-24 17/week @ 2024-10-31 74/week @ 2024-11-07

156 downloads per month

MIT license

12KB
116 lines

Quick Tracing

tracing initialization library to easily get started with tracing.

fn main() -> std:io::Result<()> {
     let _guard = quick_tracing::init()?;
     tracing::info!("Hey!");
     Ok(())
 }

Derive

Need to write the following it in Cargo.toml

quick_tracing = { version = "0.1.5", features = ["derive"] }

Attributes

  • test: Sets the test name for the logger. Log output will be written to a file named ../../logs/{test_name}.log.
  • file: Sets the file path for the log output.
  • stdio: Enables standard I/O output for the logger.(default: true)
  • level: Sets the log level filter (e.g., TRACE, DEBUG, INFO, WARN, ERROR).

Examples

#[quick_tracing::init]
fn main() {
    tracing::debug!("Hello, world!");
}
  • Debug mode + Output file

    If there is no parent directory, it will automatically create one.

[!WARNING] Panic is a possibility.

#[quick_tracing::init(level= "DEBUG", file = "./log/test.log", stdio = false)]
fn main() {
    tracing::debug!("Hello, world!");
}
  • non panic + Debug mode + Output file

    If there is no parent directory, it will automatically create one.

#[quick_tracing::try_init(level= "DEBUG", file = "./log/test.log", stdio = false)]
fn main() -> std::io::Result<()> {
    tracing::debug!("Hello, world!");
    Ok(())
}

Dependencies

~2.4–3.5MB
~65K SLoC