quick_tracing

Crates.ioquick_tracing
lib.rsquick_tracing
version0.1.5
sourcesrc
created_at2024-06-02 09:41:12.948632
updated_at2024-06-03 09:27:34.183971
descriptionA simple library to easily start tracing.
homepagehttps://github.com/SARDONYX-sard/quick_tracing
repositoryhttps://github.com/SARDONYX-sard/quick_tracing
max_upload_size
id1259105
size24,361
SARDONYX (SARDONYX-sard)

documentation

https://docs.rs/quick_tracing

README

Quick Tracing

tracing initialization library to easily get started with tracing.

docs.rs Build & Test Release License
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(())
}
Commit count: 29

cargo fmt