[初学者:我不李姐]tracing要什么使用
let subscriber = tracing_subscriber::FmtSubscriber::builder()
// all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
// will be written to stdout.
.with_max_level(Level::TRACE)
// builds the subscriber.
.finish();
tracing::subscriber::with_default(subscriber, || {
info!("This will be logged to stdout");
});
info!("This will _not_ be logged to stdout");
为什么最后一个info!("This will _not_ be logged to stdout");
不可以打印?
那后面我要打印什么写?既然info!("This will _not_ be logged to stdout");
不可以
// a builder for `FmtSubscriber`.
let subscriber = FmtSubscriber::builder()
// all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
// will be written to stdout.
.with_max_level(Level::TRACE)
// completes the builder.
.finish();
tracing::subscriber::set_global_default(subscriber)
.expect("setting default subscriber failed");
相当于设置了一个全局的subscriber订阅者;
那tracing_subscriber::f mt::init();是什么?往后info!("This will _not_ be logged to stdout");
也不可以。
我要什么使用这个tracing crate
初学rust,我不李姐;
推荐文章: