You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
754 B
Rust
25 lines
754 B
Rust
3 years ago
|
use tracing_flame::FlameLayer;
|
||
|
use tracing_subscriber::fmt::format::FmtSpan;
|
||
|
use tracing_subscriber::layer::SubscriberExt;
|
||
|
use tracing_subscriber::util::SubscriberInitExt;
|
||
|
use tracing_subscriber::{fmt, EnvFilter};
|
||
|
|
||
|
pub fn init_tracing() {
|
||
|
fmt::SubscriberBuilder::default()
|
||
|
.with_env_filter(EnvFilter::from_default_env())
|
||
|
.with_writer(std::io::stdout)
|
||
|
.with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
|
||
|
.compact()
|
||
|
.init();
|
||
|
}
|
||
|
|
||
|
pub fn init_tracing_flame() -> impl Drop {
|
||
|
let fmt_layer = fmt::Layer::default();
|
||
|
let (flame_layer, _guard) = FlameLayer::with_file("./tracing.folded").unwrap();
|
||
|
tracing_subscriber::registry()
|
||
|
.with(fmt_layer)
|
||
|
.with(flame_layer)
|
||
|
.init();
|
||
|
_guard
|
||
|
}
|