Skip to content

Commit bc2b723

Browse files
authored
readme: simplify usage with init() (console-rs#124)
1 parent 926de99 commit bc2b723

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,11 @@ others.
8686
## using it
8787

8888
to **instrument an application using Tokio**, add a dependency on the
89-
[`console-subscriber`] crate, and **add the `TasksLayer` type** to your
90-
[`tracing`] subscriber. for example:
89+
[`console-subscriber`] crate, and **add this one-liner** to the top of your
90+
`main` function:
91+
9192
```rust
92-
use tracing_subscriber::{prelude::*, fmt, EnvFilter};
93-
// construct the `console_subscriber` layer and the console wire protocol server
94-
let (layer, server) = console_subscriber::TasksLayer::new();
95-
// ensure that Tokio's internal instrumentation is enabled
96-
let filter = EnvFilter::from_default_env().add_directive("tokio=trace".parse()?);
97-
98-
tracing_subscriber::registry()
99-
// the `TasksLayer` can be used in combination with other `tracing` layers...
100-
.with(tracing_subscriber::fmt::layer())
101-
.with(filter)
102-
.with(layer)
103-
.init();
104-
105-
// spawn the server task
106-
tokio::spawn(server.serve());
93+
console_subscriber::init();
10794
```
10895

10996
notes:

0 commit comments

Comments
 (0)