Skip to content

davidbarsky/tracing-tree

Repository files navigation

tracing-tree

Instrument your application with tracing and get tree-structured summaries of your application activity with timing information on the console:

1:main┐quiet::hierarchical-example version=0.1
1:main├─┐quiet::server host="localhost", port=8080
1:main│ ├─ Xms INFO quiet starting
1:main│ ├─ Xms INFO quiet listening
1:main│ ├─┐quiet::conn peer_addr="82.9.9.9", port=42381
1:main│ │ ├─ Xms DEBUG quiet connected
1:main│ │ ├─ Xms DEBUG quiet message received, length=2
1:main│ ├─┘
1:main│ ├─┐quiet::conn peer_addr="8.8.8.8", port=18230
1:main│ │ ├─ Xms DEBUG quiet connected
1:main│ ├─┘
1:main│ ├─┐quiet::foomp 42 <- format string, normal_var=43
1:main│ │ ├─ Xms ERROR quiet hello
1:main│ ├─┘
1:main│ ├─┐quiet::conn peer_addr="82.9.9.9", port=42381
1:main│ │ ├─ Xms WARN quiet weak encryption requested, algo="xor"
1:main│ │ ├─ Xms DEBUG quiet response sent, length=8
1:main│ │ ├─ Xms DEBUG quiet disconnected
1:main│ ├─┘
1:main│ ├─┐quiet::conn peer_addr="8.8.8.8", port=18230
1:main│ │ ├─ Xms DEBUG quiet message received, length=5
1:main│ │ ├─ Xms DEBUG quiet response sent, length=8
1:main│ │ ├─ Xms DEBUG quiet disconnected
1:main│ ├─┘
1:main│ ├─ Xs WARN quiet internal error
1:main│ ├─ Xs INFO quiet exit
1:main├─┘
1:main┘

(Format inspired by slog-term)

Setup

After instrumenting your app with tracing, add this subscriber like this:

let subscriber = Registry::default().with(HierarchicalLayer::new(2));
tracing::subscriber::set_global_default(subscriber).unwrap();