Skip to content

Commit 3559ede

Browse files
original indent behaviour
1 parent 12ac87f commit 3559ede

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

examples/basic.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ use tracing::{debug, error, info, instrument, span, warn, Level};
22
use tracing_subscriber::{layer::SubscriberExt, registry::Registry};
33
use tracing_tree::HierarchicalLayer;
44

5+
#[derive(Debug)]
6+
struct PrettyPrintMe {
7+
value_a: u32,
8+
value_b: String,
9+
}
10+
511
fn main() {
612
let layer = HierarchicalLayer::default()
713
.with_writer(std::io::stdout)
@@ -50,6 +56,18 @@ fn main() {
5056
error!("hello");
5157
});
5258
drop(peer3);
59+
let val = format!(
60+
"{:#?}",
61+
PrettyPrintMe {
62+
value_a: 42,
63+
value_b: "hello".into(),
64+
}
65+
);
66+
let peer3 = span!(Level::TRACE, "", val = %val);
67+
peer3.in_scope(|| {
68+
error!("hello");
69+
});
70+
drop(peer3);
5371
let peer1 = span!(Level::TRACE, "conn", peer_addr = "82.9.9.9", port = 42381);
5472
peer1.in_scope(|| {
5573
warn!(algo = "xor", "weak encryption requested");

examples/basic.stdout

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
1:main ┌┘basic::foomp 42 <- format string, normal_var=43
2121
1:main ┌┘basic::server host="localhost", port=8080
2222
1:main └┐basic::server host="localhost", port=8080
23+
1:main └┐basic:: val=PrettyPrintMe {
24+
1:main │ value_a: 42,
25+
1:main │ value_b: "hello",
26+
1:main │ }
27+
1:main ├─ ERROR basic hello
28+
1:main ┌┘basic:: val=PrettyPrintMe {
29+
1:main │ value_a: 42,
30+
1:main │ value_b: "hello",
31+
1:main │ }
32+
1:main ┌┘basic::server host="localhost", port=8080
33+
1:main └┐basic::server host="localhost", port=8080
2334
1:main └┐basic::conn peer_addr="82.9.9.9", port=42381
2435
1:main ├─ WARN basic weak encryption requested, algo="xor"
2536
1:main ├─ DEBUG basic response sent, length=8

examples/no-indent.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ use tracing::{debug, error, info, instrument, span, warn, Level};
22
use tracing_subscriber::{layer::SubscriberExt, registry::Registry};
33
use tracing_tree::HierarchicalLayer;
44

5+
#[derive(Debug)]
6+
struct PrettyPrintMe {
7+
value_a: u32,
8+
value_b: String,
9+
}
10+
511
fn main() {
612
let layer = HierarchicalLayer::default()
713
.with_writer(std::io::stdout)
@@ -47,6 +53,18 @@ fn main() {
4753
error!("hello");
4854
});
4955
drop(peer3);
56+
let val = format!(
57+
"{:#?}",
58+
PrettyPrintMe {
59+
value_a: 42,
60+
value_b: "hello".into(),
61+
}
62+
);
63+
let peer3 = span!(Level::TRACE, "", val = %val);
64+
peer3.in_scope(|| {
65+
error!("hello");
66+
});
67+
drop(peer3);
5068
let peer1 = span!(Level::TRACE, "conn", peer_addr = "82.9.9.9", port = 42381);
5169
peer1.in_scope(|| {
5270
warn!(algo = "xor", "weak encryption requested");

examples/no-indent.stdout

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
1:main DEBUG no_indent connected
1010
1:main no_indent::foomp 42 <- format string, normal_var=43
1111
1:main ERROR no_indent hello
12+
1:main no_indent:: val=PrettyPrintMe {
13+
1:main value_a: 42,
14+
1:main value_b: "hello",
15+
1:main }
16+
1:main ERROR no_indent hello
1217
1:main no_indent::conn peer_addr="82.9.9.9", port=42381
1318
1:main WARN no_indent weak encryption requested, algo="xor"
1419
1:main DEBUG no_indent response sent, length=8

0 commit comments

Comments
 (0)