feat: add tracing crate (#236)

This commit is contained in:
Matthias Seitz
2022-11-22 20:48:32 +01:00
committed by GitHub
parent 4fd1225dd6
commit 89ffaf541b
4 changed files with 44 additions and 1 deletions

12
crates/tracing/Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "reth-tracing"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/foundry-rs/reth"
readme = "README.md"
description = "tracing helpers"
[dependencies]
tracing = { version = "0.1", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] }

22
crates/tracing/src/lib.rs Normal file
View File

@ -0,0 +1,22 @@
#![warn(missing_docs, unreachable_pub)]
#![deny(unused_must_use, rust_2018_idioms)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
//! reth-tracing
// re-export tracing crates.
pub use tracing;
pub use tracing_subscriber;
/// Initialises a tracing subscriber via `RUST_LOG` environment variable filter.
///
/// Note: This ignores any error and should be used for testing.
pub fn init_tracing() {
let _ = tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_writer(std::io::stderr)
.try_init();
}