mirror of
https://git.proxmox.com/git/rustc
synced 2025-08-18 17:53:22 +00:00
38 lines
1.4 KiB
Markdown
38 lines
1.4 KiB
Markdown
# tracing-tree
|
|
|
|
Instrument your application with [tracing](https://github.com/tokio-rs/tracing)
|
|
and get tree-structured summaries of your application activity with timing
|
|
information on the console:
|
|
|
|
<pre>
|
|
<b>server</b>{host="localhost", port=8080<b>}</b>
|
|
0ms <b> INFO</b> starting
|
|
300ms <b> INFO</b> listening
|
|
<b>conn</b>{peer_addr="82.9.9.9", port=42381<b>}</b>
|
|
0ms <b>DEBUG</b> connected
|
|
300ms <b>DEBUG</b> message received, length=2
|
|
<b>conn</b>{peer_addr="8.8.8.8", port=18230<b>}</b>
|
|
300ms <b>DEBUG</b> connected
|
|
<b>conn</b>{peer_addr="82.9.9.9", port=42381<b>}</b>
|
|
600ms <b> WARN</b> weak encryption requested, algo="xor"
|
|
901ms <b>DEBUG</b> response sent, length=8
|
|
901ms <b>DEBUG</b> disconnected
|
|
<b>conn</b>{peer_addr="8.8.8.8", port=18230<b>}</b>
|
|
600ms <b>DEBUG</b> message received, length=5
|
|
901ms <b>DEBUG</b> response sent, length=8
|
|
901ms <b>DEBUG</b> disconnected
|
|
1502ms <b> WARN</b> internal error
|
|
1502ms <b> INFO</b> exit
|
|
</pre>
|
|
|
|
(Format inspired by [slog-term](https://github.com/slog-rs/slog#terminal-output-example))
|
|
|
|
## Setup
|
|
|
|
After instrumenting your app with
|
|
[tracing](https://github.com/tokio-rs/tracing), add this subscriber like this:
|
|
|
|
```rust
|
|
let subscriber = Registry::default().with(HierarchicalLayer::new(2));
|
|
tracing::subscriber::set_global_default(subscriber).unwrap();
|
|
``` |