diff --git a/examples/basic.stdout b/examples/basic.stdout index 24f7fdf..9258597 100644 --- a/examples/basic.stdout +++ b/examples/basic.stdout @@ -1,41 +1,92 @@ -1:main┐basic::hierarchical-example version=0.1 -1:main└┐basic::hierarchical-example version=0.1 -1:main └┐basic::server host="localhost", port=8080 +1:main┬─┬─ basic::hierarchical-example +1:main│ └─ version=0.1 +1:main└┬─┬─ basic::hierarchical-example +1:main │ └─ version=0.1 +1:main └┬─┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ INFO basic starting 1:main ├─ INFO basic listening -1:main └┐basic::server host="localhost", port=8080 -1:main └┐basic::conn peer_addr="82.9.9.9", port=42381 +1:main └┬─┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─ DEBUG basic connected -1:main ├─ DEBUG basic message received, length=2 -1:main ┌┘basic::conn peer_addr="82.9.9.9", port=42381 -1:main ┌┘basic::server host="localhost", port=8080 -1:main └┐basic::server host="localhost", port=8080 -1:main └┐basic::conn peer_addr="8.8.8.8", port=18230 +1:main ├─┬─ DEBUG basic message received +1:main │ └─ length=2 +1:main ┌┴┬─ basic::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌┴┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 1:main ├─ DEBUG basic connected -1:main ┌┘basic::conn peer_addr="8.8.8.8", port=18230 -1:main ┌┘basic::server host="localhost", port=8080 -1:main └┐basic::server host="localhost", port=8080 -1:main └┐basic::foomp 42 <- format string, normal_var=43 +1:main ┌┴┬─ basic::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ┌┴┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::foomp 42 <- format string +1:main │ └─ normal_var=43 1:main ├─ ERROR basic hello -1:main ┌┘basic::foomp 42 <- format string, normal_var=43 -1:main ┌┘basic::server host="localhost", port=8080 -1:main └┐basic::server host="localhost", port=8080 -1:main └┐basic::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ WARN basic weak encryption requested, algo="xor" -1:main ├─ DEBUG basic response sent, length=8 +1:main ┌┴┬─ basic::foomp 42 <- format string +1:main │ └─ normal_var=43 +1:main ┌┴┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ WARN basic weak encryption requested +1:main │ └─ algo="xor" +1:main ├─┬─ DEBUG basic response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic disconnected -1:main ┌┘basic::conn peer_addr="82.9.9.9", port=42381 -1:main ┌┘basic::server host="localhost", port=8080 -1:main └┐basic::server host="localhost", port=8080 -1:main └┐basic::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG basic message received, length=5 -1:main ├─ DEBUG basic response sent, length=8 +1:main ┌┴┬─ basic::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌┴┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG basic message received +1:main │ └─ length=5 +1:main ├─┬─ DEBUG basic response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic disconnected -1:main ┌┘basic::conn peer_addr="8.8.8.8", port=18230 -1:main ┌┘basic::server host="localhost", port=8080 +1:main ┌┴┬─ basic::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ┌┴┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ WARN basic internal error 1:main ├─ ERROR basic this is a log message 1:main ├─ INFO basic exit -1:main ┌┘basic::server host="localhost", port=8080 -1:main┌┘basic::hierarchical-example version=0.1 -1:main┘basic::hierarchical-example version=0.1 +1:main ┌┴┬─ basic::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main┌┴┬─ basic::hierarchical-example +1:main│ └─ version=0.1 +1:main┴┬─ basic::hierarchical-example +1:main └─ version=0.1 diff --git a/examples/basic_non_verbose.stdout b/examples/basic_non_verbose.stdout index 0a02bbc..8f217d4 100644 --- a/examples/basic_non_verbose.stdout +++ b/examples/basic_non_verbose.stdout @@ -1,25 +1,42 @@ -1:main┐basic_non_verbose::hierarchical-example version=0.1 -1:main└─┐basic_non_verbose::server host="localhost", port=8080 +1:main┬─┬─ basic_non_verbose::hierarchical-example +1:main│ └─ version=0.1 +1:main└─┬─┬─ basic_non_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ INFO basic_non_verbose starting 1:main ├─ INFO basic_non_verbose listening -1:main └─┐basic_non_verbose::conn peer_addr="82.9.9.9", port=42381 +1:main └─┬─┬─ basic_non_verbose::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─ DEBUG basic_non_verbose connected -1:main ├─ DEBUG basic_non_verbose message received, length=2 +1:main ├─┬─ DEBUG basic_non_verbose message received +1:main │ └─ length=2 1:main ┌─┘ -1:main └─┐basic_non_verbose::conn peer_addr="8.8.8.8", port=18230 +1:main └─┬─┬─ basic_non_verbose::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 1:main ├─ DEBUG basic_non_verbose connected 1:main ┌─┘ -1:main └─┐basic_non_verbose::foomp 42 <- format string, normal_var=43 +1:main └─┬─┬─ basic_non_verbose::foomp 42 <- format string +1:main │ └─ normal_var=43 1:main ├─ ERROR basic_non_verbose hello 1:main ┌─┘ -1:main └─┐basic_non_verbose::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ WARN basic_non_verbose weak encryption requested, algo="xor" -1:main ├─ DEBUG basic_non_verbose response sent, length=8 +1:main └─┬─┬─ basic_non_verbose::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ WARN basic_non_verbose weak encryption requested +1:main │ └─ algo="xor" +1:main ├─┬─ DEBUG basic_non_verbose response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic_non_verbose disconnected 1:main ┌─┘ -1:main └─┐basic_non_verbose::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG basic_non_verbose message received, length=5 -1:main ├─ DEBUG basic_non_verbose response sent, length=8 +1:main └─┬─┬─ basic_non_verbose::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG basic_non_verbose message received +1:main │ └─ length=5 +1:main ├─┬─ DEBUG basic_non_verbose response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic_non_verbose disconnected 1:main ┌─┘ 1:main ├─ WARN basic_non_verbose internal error diff --git a/examples/basic_verbose_entry.stdout b/examples/basic_verbose_entry.stdout index f85badf..b5e0ed0 100644 --- a/examples/basic_verbose_entry.stdout +++ b/examples/basic_verbose_entry.stdout @@ -1,31 +1,59 @@ -1:main┐basic_verbose_entry::hierarchical-example version=0.1 -1:main└┐basic_verbose_entry::hierarchical-example version=0.1 -1:main └┐basic_verbose_entry::server host="localhost", port=8080 +1:main┬─┬─ basic_verbose_entry::hierarchical-example +1:main│ └─ version=0.1 +1:main└┬─┬─ basic_verbose_entry::hierarchical-example +1:main │ └─ version=0.1 +1:main └┬─┬─ basic_verbose_entry::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ INFO basic_verbose_entry starting 1:main ├─ INFO basic_verbose_entry listening -1:main └┐basic_verbose_entry::server host="localhost", port=8080 -1:main └┐basic_verbose_entry::conn peer_addr="82.9.9.9", port=42381 +1:main └┬─┬─ basic_verbose_entry::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic_verbose_entry::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─ DEBUG basic_verbose_entry connected -1:main ├─ DEBUG basic_verbose_entry message received, length=2 +1:main ├─┬─ DEBUG basic_verbose_entry message received +1:main │ └─ length=2 1:main ┌─┘ -1:main └┐basic_verbose_entry::server host="localhost", port=8080 -1:main └┐basic_verbose_entry::conn peer_addr="8.8.8.8", port=18230 +1:main └┬─┬─ basic_verbose_entry::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic_verbose_entry::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 1:main ├─ DEBUG basic_verbose_entry connected 1:main ┌─┘ -1:main └┐basic_verbose_entry::server host="localhost", port=8080 -1:main └┐basic_verbose_entry::foomp 42 <- format string, normal_var=43 +1:main └┬─┬─ basic_verbose_entry::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic_verbose_entry::foomp 42 <- format string +1:main │ └─ normal_var=43 1:main ├─ ERROR basic_verbose_entry hello 1:main ┌─┘ -1:main └┐basic_verbose_entry::server host="localhost", port=8080 -1:main └┐basic_verbose_entry::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ WARN basic_verbose_entry weak encryption requested, algo="xor" -1:main ├─ DEBUG basic_verbose_entry response sent, length=8 +1:main └┬─┬─ basic_verbose_entry::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic_verbose_entry::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ WARN basic_verbose_entry weak encryption requested +1:main │ └─ algo="xor" +1:main ├─┬─ DEBUG basic_verbose_entry response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic_verbose_entry disconnected 1:main ┌─┘ -1:main └┐basic_verbose_entry::server host="localhost", port=8080 -1:main └┐basic_verbose_entry::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG basic_verbose_entry message received, length=5 -1:main ├─ DEBUG basic_verbose_entry response sent, length=8 +1:main └┬─┬─ basic_verbose_entry::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┬─┬─ basic_verbose_entry::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG basic_verbose_entry message received +1:main │ └─ length=5 +1:main ├─┬─ DEBUG basic_verbose_entry response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic_verbose_entry disconnected 1:main ┌─┘ 1:main ├─ WARN basic_verbose_entry internal error diff --git a/examples/basic_verbose_exit.stdout b/examples/basic_verbose_exit.stdout index fbfada3..0704c70 100644 --- a/examples/basic_verbose_exit.stdout +++ b/examples/basic_verbose_exit.stdout @@ -1,35 +1,75 @@ -1:main┐basic_verbose_exit::hierarchical-example version=0.1 -1:main└─┐basic_verbose_exit::server host="localhost", port=8080 +1:main┬─┬─ basic_verbose_exit::hierarchical-example +1:main│ └─ version=0.1 +1:main└─┬─┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ INFO basic_verbose_exit starting 1:main ├─ INFO basic_verbose_exit listening -1:main └─┐basic_verbose_exit::conn peer_addr="82.9.9.9", port=42381 +1:main └─┬─┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─ DEBUG basic_verbose_exit connected -1:main ├─ DEBUG basic_verbose_exit message received, length=2 -1:main ┌┘basic_verbose_exit::conn peer_addr="82.9.9.9", port=42381 -1:main ┌┘basic_verbose_exit::server host="localhost", port=8080 -1:main └─┐basic_verbose_exit::conn peer_addr="8.8.8.8", port=18230 +1:main ├─┬─ DEBUG basic_verbose_exit message received +1:main │ └─ length=2 +1:main ┌┴┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌┴┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┬─┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 1:main ├─ DEBUG basic_verbose_exit connected -1:main ┌┘basic_verbose_exit::conn peer_addr="8.8.8.8", port=18230 -1:main ┌┘basic_verbose_exit::server host="localhost", port=8080 -1:main └─┐basic_verbose_exit::foomp 42 <- format string, normal_var=43 +1:main ┌┴┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ┌┴┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┬─┬─ basic_verbose_exit::foomp 42 <- format string +1:main │ └─ normal_var=43 1:main ├─ ERROR basic_verbose_exit hello -1:main ┌┘basic_verbose_exit::foomp 42 <- format string, normal_var=43 -1:main ┌┘basic_verbose_exit::server host="localhost", port=8080 -1:main └─┐basic_verbose_exit::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ WARN basic_verbose_exit weak encryption requested, algo="xor" -1:main ├─ DEBUG basic_verbose_exit response sent, length=8 +1:main ┌┴┬─ basic_verbose_exit::foomp 42 <- format string +1:main │ └─ normal_var=43 +1:main ┌┴┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┬─┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ WARN basic_verbose_exit weak encryption requested +1:main │ └─ algo="xor" +1:main ├─┬─ DEBUG basic_verbose_exit response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic_verbose_exit disconnected -1:main ┌┘basic_verbose_exit::conn peer_addr="82.9.9.9", port=42381 -1:main ┌┘basic_verbose_exit::server host="localhost", port=8080 -1:main └─┐basic_verbose_exit::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG basic_verbose_exit message received, length=5 -1:main ├─ DEBUG basic_verbose_exit response sent, length=8 +1:main ┌┴┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌┴┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┬─┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG basic_verbose_exit message received +1:main │ └─ length=5 +1:main ├─┬─ DEBUG basic_verbose_exit response sent +1:main │ └─ length=8 1:main ├─ DEBUG basic_verbose_exit disconnected -1:main ┌┘basic_verbose_exit::conn peer_addr="8.8.8.8", port=18230 -1:main ┌┘basic_verbose_exit::server host="localhost", port=8080 +1:main ┌┴┬─ basic_verbose_exit::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ┌┴┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ WARN basic_verbose_exit internal error 1:main ├─ ERROR basic_verbose_exit this is a log message 1:main ├─ INFO basic_verbose_exit exit -1:main ┌┘basic_verbose_exit::server host="localhost", port=8080 -1:main┌┘basic_verbose_exit::hierarchical-example version=0.1 -1:main┘basic_verbose_exit::hierarchical-example version=0.1 +1:main ┌┴┬─ basic_verbose_exit::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main┌┴┬─ basic_verbose_exit::hierarchical-example +1:main│ └─ version=0.1 +1:main┴┬─ basic_verbose_exit::hierarchical-example +1:main └─ version=0.1 diff --git a/examples/concurrent.stdout b/examples/concurrent.stdout index 6429b68..2fe68a7 100644 --- a/examples/concurrent.stdout +++ b/examples/concurrent.stdout @@ -1,19 +1,32 @@ -1:main┐concurrent::hierarchical-example version=0.1 -1:main└───┐concurrent::server host="localhost", port=8080 +1:main┬───┬─── concurrent::hierarchical-example +1:main│ └─ version=0.1 +1:main└───┬───┬─── concurrent::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─── INFO concurrent starting 1:main ├─── INFO concurrent listening 1:main ├─── DEBUG concurrent starting countdowns -1:main └───┐concurrent::countdowns -1:main └───┐concurrent::countdown_a -1:main ├─── DEBUG concurrent polling countdown, label="a", count=3 -1:main └───┐concurrent::countdown_b -1:main ├─── DEBUG concurrent polling countdown, label="b", count=5 -1:main ├─── DEBUG concurrent polling countdown, label="b", count=4 -1:main └───┐concurrent::countdown_a -1:main ├─── DEBUG concurrent polling countdown, label="a", count=2 -1:main └───┐concurrent::conn peer_addr="82.9.9.9", port=42381 +1:main └───┐concurrent::countdowns +1:main └───┐concurrent::countdown_a +1:main ├───┬─── DEBUG concurrent polling countdown +1:main │ ├─ label="a" +1:main │ └─ count=3 +1:main └───┐concurrent::countdown_b +1:main ├───┬─── DEBUG concurrent polling countdown +1:main │ ├─ label="b" +1:main │ └─ count=5 +1:main ├───┬─── DEBUG concurrent polling countdown +1:main │ ├─ label="b" +1:main │ └─ count=4 +1:main └───┐concurrent::countdown_a +1:main ├───┬─── DEBUG concurrent polling countdown +1:main │ ├─ label="a" +1:main │ └─ count=2 +1:main └───┬───┬─── concurrent::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─── WARN concurrent peer1 warning -1:main └───┐concurrent::countdowns +1:main └───┐concurrent::countdowns 1:main ├─── INFO concurrent finished polling countdowns 1:main ┌───┘ 1:main ┌───┘ diff --git a/examples/concurrent_eager.stdout b/examples/concurrent_eager.stdout index d8d9411..4fafff1 100644 --- a/examples/concurrent_eager.stdout +++ b/examples/concurrent_eager.stdout @@ -1,15 +1,21 @@ -1:main┐concurrent_eager::spawn_fut key="a" -1:main┐concurrent_eager::spawn_fut key="b" -1:main┐concurrent_eager::spawn_fut key="a" -1:main└───┐concurrent_eager::a -1:main┐concurrent_eager::spawn_fut key="b" -1:main└───┐concurrent_eager::b -1:main┐concurrent_eager::spawn_fut key="a" -1:main└───┐concurrent_eager::a +1:main┬───┬─── concurrent_eager::spawn_fut +1:main│ └─ key="a" +1:main┬───┬─── concurrent_eager::spawn_fut +1:main│ └─ key="b" +1:main┬───┬─── concurrent_eager::spawn_fut +1:main│ └─ key="a" +1:main└───┐concurrent_eager::a +1:main┬───┬─── concurrent_eager::spawn_fut +1:main│ └─ key="b" +1:main└───┐concurrent_eager::b +1:main┬───┬─── concurrent_eager::spawn_fut +1:main│ └─ key="a" +1:main└───┐concurrent_eager::a 1:main ├─── INFO concurrent_eager a 1:main┌───┘ -1:main┐concurrent_eager::spawn_fut key="b" -1:main└───┐concurrent_eager::b +1:main┬───┬─── concurrent_eager::spawn_fut +1:main│ └─ key="b" +1:main└───┐concurrent_eager::b 1:main ├─── INFO concurrent_eager b 1:main┌───┘ 1:main┘ diff --git a/examples/concurrent_verbose.stdout b/examples/concurrent_verbose.stdout index d2ea058..fe4e5bc 100644 --- a/examples/concurrent_verbose.stdout +++ b/examples/concurrent_verbose.stdout @@ -1,35 +1,64 @@ -1:main┐concurrent_verbose::hierarchical-example version=0.1 -1:main└───┐concurrent_verbose::server host="localhost", port=8080 +1:main┬───┬─── concurrent_verbose::hierarchical-example +1:main│ └─ version=0.1 +1:main└───┬───┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─── INFO concurrent_verbose starting 1:main ├─── INFO concurrent_verbose listening 1:main ├─── DEBUG concurrent_verbose starting countdowns -1:main └─┐concurrent_verbose::server host="localhost", port=8080 -1:main └─┐concurrent_verbose::countdowns -1:main └───┐concurrent_verbose::countdown_a -1:main ├─── DEBUG concurrent_verbose polling countdown, label="a", count=3 -1:main └─┐concurrent_verbose::countdowns -1:main └─┐concurrent_verbose::countdown_b -1:main ├─── DEBUG concurrent_verbose polling countdown, label="b", count=5 -1:main ├─── DEBUG concurrent_verbose polling countdown, label="b", count=4 -1:main └─┐concurrent_verbose::countdowns -1:main └─┐concurrent_verbose::countdown_a -1:main ├─── DEBUG concurrent_verbose polling countdown, label="a", count=2 -1:main └─┐concurrent_verbose::server host="localhost", port=8080 -1:main └─┐concurrent_verbose::conn peer_addr="82.9.9.9", port=42381 +1:main └─┬───┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┐concurrent_verbose::countdowns +1:main └───┐concurrent_verbose::countdown_a +1:main ├───┬─── DEBUG concurrent_verbose polling countdown +1:main │ ├─ label="a" +1:main │ └─ count=3 +1:main └─┐concurrent_verbose::countdowns +1:main └─┐concurrent_verbose::countdown_b +1:main ├───┬─── DEBUG concurrent_verbose polling countdown +1:main │ ├─ label="b" +1:main │ └─ count=5 +1:main ├───┬─── DEBUG concurrent_verbose polling countdown +1:main │ ├─ label="b" +1:main │ └─ count=4 +1:main └─┐concurrent_verbose::countdowns +1:main └─┐concurrent_verbose::countdown_a +1:main ├───┬─── DEBUG concurrent_verbose polling countdown +1:main │ ├─ label="a" +1:main │ └─ count=2 +1:main └─┬───┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┬───┬─── concurrent_verbose::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─── WARN concurrent_verbose peer1 warning -1:main └─┐concurrent_verbose::server host="localhost", port=8080 -1:main └─┐concurrent_verbose::countdowns +1:main └─┬───┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └─┐concurrent_verbose::countdowns 1:main ├─── INFO concurrent_verbose finished polling countdowns -1:main ┌─┘concurrent_verbose::countdown_b -1:main ┌─┘concurrent_verbose::countdowns -1:main ┌─┘concurrent_verbose::countdown_a -1:main ┌─┘concurrent_verbose::countdowns -1:main ┌─┘concurrent_verbose::countdowns -1:main ┌─┘concurrent_verbose::server host="localhost", port=8080 -1:main ┌─┘concurrent_verbose::conn peer_addr="82.9.9.9", port=42381 -1:main ┌─┘concurrent_verbose::server host="localhost", port=8080 +1:main ┌─┘concurrent_verbose::countdown_b +1:main ┌─┘concurrent_verbose::countdowns +1:main ┌─┘concurrent_verbose::countdown_a +1:main ┌─┘concurrent_verbose::countdowns +1:main ┌─┘concurrent_verbose::countdowns +1:main ┌─┴──┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main ┌─┴──┬─── concurrent_verbose::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌─┴──┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─── INFO concurrent_verbose all done! 1:main ├─── INFO concurrent_verbose exit -1:main ┌─┘concurrent_verbose::server host="localhost", port=8080 -1:main┌─┘concurrent_verbose::hierarchical-example version=0.1 -1:main┘concurrent_verbose::hierarchical-example version=0.1 +1:main ┌─┴──┬─── concurrent_verbose::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main┌─┴──┬─── concurrent_verbose::hierarchical-example +1:main │ └─ version=0.1 +1:main┴──┬─── concurrent_verbose::hierarchical-example +1:main └─ version=0.1 diff --git a/examples/deferred.stdout b/examples/deferred.stdout index e5335b9..45c2ae0 100644 --- a/examples/deferred.stdout +++ b/examples/deferred.stdout @@ -1,45 +1,81 @@ -> This prints before the span open message -1:main┐open: deferred::hierarchical-example version=0.1 -1:main└─┐open: deferred::server host="localhost", port=8080 +1:main┬─┬─ open: deferred::hierarchical-example +1:main│ └─ version=0.1 +1:main└─┬─┬─ open: deferred::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ INFO deferred starting 1:main ├─ INFO deferred listening -> Deferring two levels of spans -1:main └┐pre_open: deferred::server host="localhost", port=8080 -1:main └┐open(v): deferred::connections -1:main └─┐open: deferred::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ DEBUG deferred connected, peer="peer1" -1:main ├─ DEBUG deferred message received, length=2 -1:main ┌┘close(v): deferred::conn peer_addr="82.9.9.9", port=42381 -1:main ┌┘post_close: deferred::connections -1:main └┐pre_open: deferred::connections -1:main └┐open(v): deferred::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG deferred connected, peer="peer3" -1:main ┌┘close(v): deferred::conn peer_addr="8.8.8.8", port=18230 -1:main ┌┘post_close: deferred::connections -1:main └┐pre_open: deferred::connections -1:main └┐open(v): deferred::foomp 42 <- format string, normal_var=43 +1:main └┬─┬─ pre_open: deferred::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main └┐open(v): deferred::connections +1:main └─┬─┬─ open: deferred::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ DEBUG deferred connected +1:main │ └─ peer="peer1" +1:main ├─┬─ DEBUG deferred message received +1:main │ └─ length=2 +1:main ┌┴┬─ close(v): deferred::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌┘post_close: deferred::connections +1:main └┐pre_open: deferred::connections +1:main └┬─┬─ open(v): deferred::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG deferred connected +1:main │ └─ peer="peer3" +1:main ┌┴┬─ close(v): deferred::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ┌┘post_close: deferred::connections +1:main └┐pre_open: deferred::connections +1:main └┬─┬─ open(v): deferred::foomp 42 <- format string +1:main │ └─ normal_var=43 1:main ├─ ERROR deferred hello -1:main ┌┘close(v): deferred::foomp 42 <- format string, normal_var=43 -1:main ┌┘post_close: deferred::connections -1:main └┐pre_open: deferred::connections -1:main └┐open(v): deferred::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ WARN deferred weak encryption requested, algo="xor" -1:main ├─ DEBUG deferred response sent, length=8 +1:main ┌┴┬─ close(v): deferred::foomp 42 <- format string +1:main │ └─ normal_var=43 +1:main ┌┘post_close: deferred::connections +1:main └┐pre_open: deferred::connections +1:main └┬─┬─ open(v): deferred::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ WARN deferred weak encryption requested +1:main │ └─ algo="xor" +1:main ├─┬─ DEBUG deferred response sent +1:main │ └─ length=8 1:main ├─ DEBUG deferred disconnected -1:main ┌┘close(v): deferred::conn peer_addr="82.9.9.9", port=42381 -1:main ┌┘post_close: deferred::connections -1:main └┐pre_open: deferred::connections -1:main └┐open(v): deferred::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG deferred message received, length=5 -1:main ├─ DEBUG deferred response sent, length=8 +1:main ┌┴┬─ close(v): deferred::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ┌┘post_close: deferred::connections +1:main └┐pre_open: deferred::connections +1:main └┬─┬─ open(v): deferred::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG deferred message received +1:main │ └─ length=5 +1:main ├─┬─ DEBUG deferred response sent +1:main │ └─ length=8 1:main ├─ DEBUG deferred disconnected -1:main ┌┘close(v): deferred::conn peer_addr="8.8.8.8", port=18230 -1:main ┌┘post_close: deferred::connections -1:main ┌┘close(v): deferred::connections -1:main ┌┘post_close: deferred::server host="localhost", port=8080 +1:main ┌┴┬─ close(v): deferred::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ┌┘post_close: deferred::connections +1:main ┌┘close(v): deferred::connections +1:main ┌┴┬─ post_close: deferred::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ WARN deferred internal error 1:main ├─ ERROR deferred this is a log message 1:main ├─ INFO deferred exit -1:main ┌┘close(v): deferred::server host="localhost", port=8080 -1:main┌┘post_close: deferred::hierarchical-example version=0.1 -1:main┘close(v): deferred::hierarchical-example version=0.1 +1:main ┌┴┬─ close(v): deferred::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 +1:main┌┴┬─ post_close: deferred::hierarchical-example +1:main│ └─ version=0.1 +1:main┴┬─ close(v): deferred::hierarchical-example +1:main └─ version=0.1 diff --git a/examples/quiet.stdout b/examples/quiet.stdout index 5eddea7..3226e8e 100644 --- a/examples/quiet.stdout +++ b/examples/quiet.stdout @@ -1,25 +1,42 @@ -1:main┐quiet::hierarchical-example version=0.1 -1:main└─┐quiet::server host="localhost", port=8080 +1:main┬─┬─ quiet::hierarchical-example +1:main│ └─ version=0.1 +1:main└─┬─┬─ quiet::server +1:main │ ├─ host="localhost" +1:main │ └─ port=8080 1:main ├─ INFO quiet starting 1:main ├─ INFO quiet listening -1:main └─┐quiet::conn peer_addr="82.9.9.9", port=42381 +1:main └─┬─┬─ quiet::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 1:main ├─ DEBUG quiet connected -1:main ├─ DEBUG quiet message received, length=2 +1:main ├─┬─ DEBUG quiet message received +1:main │ └─ length=2 1:main ┌─┘ -1:main └─┐quiet::conn peer_addr="8.8.8.8", port=18230 +1:main └─┬─┬─ quiet::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 1:main ├─ DEBUG quiet connected 1:main ┌─┘ -1:main └─┐quiet::foomp 42 <- format string, normal_var=43 +1:main └─┬─┬─ quiet::foomp 42 <- format string +1:main │ └─ normal_var=43 1:main ├─ ERROR quiet hello 1:main ┌─┘ -1:main └─┐quiet::conn peer_addr="82.9.9.9", port=42381 -1:main ├─ WARN quiet weak encryption requested, algo="xor" -1:main ├─ DEBUG quiet response sent, length=8 +1:main └─┬─┬─ quiet::conn +1:main │ ├─ peer_addr="82.9.9.9" +1:main │ └─ port=42381 +1:main ├─┬─ WARN quiet weak encryption requested +1:main │ └─ algo="xor" +1:main ├─┬─ DEBUG quiet response sent +1:main │ └─ length=8 1:main ├─ DEBUG quiet disconnected 1:main ┌─┘ -1:main └─┐quiet::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ DEBUG quiet message received, length=5 -1:main ├─ DEBUG quiet response sent, length=8 +1:main └─┬─┬─ quiet::conn +1:main │ ├─ peer_addr="8.8.8.8" +1:main │ └─ port=18230 +1:main ├─┬─ DEBUG quiet message received +1:main │ └─ length=5 +1:main ├─┬─ DEBUG quiet response sent +1:main │ └─ length=8 1:main ├─ DEBUG quiet disconnected 1:main ┌─┘ 1:main ├─ WARN quiet internal error diff --git a/examples/wraparound.stdout b/examples/wraparound.stdout index 8f9c67d..5212b7e 100644 --- a/examples/wraparound.stdout +++ b/examples/wraparound.stdout @@ -1,50 +1,72 @@ -1:main┐wraparound::recurse i=0 +1:main┬─┬─ wraparound::recurse +1:main│ └─ i=0 1:main├─ WARN wraparound boop -1:main└─┐wraparound::recurse i=1 +1:main└─┬─┬─ wraparound::recurse +1:main │ └─ i=1 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=2 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=2 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=3 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=3 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=4 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=4 1:main────────┘ 1:main WARN wraparound boop -1:main┐wraparound::recurse i=5 +1:main┬─┬─ wraparound::recurse +1:main│ └─ i=5 1:main├─ WARN wraparound boop -1:main└─┐wraparound::recurse i=6 +1:main└─┬─┬─ wraparound::recurse +1:main │ └─ i=6 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=7 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=7 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=8 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=8 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=9 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=9 1:main────────┘ 1:main WARN wraparound boop -1:main┐wraparound::recurse i=10 +1:main┬─┬─ wraparound::recurse +1:main│ └─ i=10 1:main├─ WARN wraparound boop -1:main└─┐wraparound::recurse i=11 +1:main└─┬─┬─ wraparound::recurse +1:main │ └─ i=11 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=12 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=12 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=13 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=13 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=14 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=14 1:main────────┘ 1:main WARN wraparound boop -1:main┐wraparound::recurse i=15 +1:main┬─┬─ wraparound::recurse +1:main│ └─ i=15 1:main├─ WARN wraparound boop -1:main└─┐wraparound::recurse i=16 +1:main└─┬─┬─ wraparound::recurse +1:main │ └─ i=16 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=17 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=17 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=18 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=18 1:main ├─ WARN wraparound boop -1:main └─┐wraparound::recurse i=19 +1:main └─┬─┬─ wraparound::recurse +1:main │ └─ i=19 1:main────────┘ 1:main WARN wraparound boop -1:main┐wraparound::recurse i=20 +1:main┬─┬─ wraparound::recurse +1:main│ └─ i=20 1:main├─ WARN wraparound boop -1:main└─┐wraparound::recurse i=21 +1:main└─┬─┬─ wraparound::recurse +1:main │ └─ i=21 1:main ├─ WARN wraparound boop 1:main ├─ WARN wraparound bop 1:main┌─┘ diff --git a/src/format.rs b/src/format.rs index 84b904b..28a1314 100644 --- a/src/format.rs +++ b/src/format.rs @@ -14,6 +14,7 @@ pub(crate) const LINE_BRANCH: &str = "├"; pub(crate) const LINE_CLOSE: &str = "┘"; pub(crate) const LINE_CLOSE2: char = '┌'; pub(crate) const LINE_OPEN: &str = "┐"; +pub(crate) const ARGS_BRANCH: &str = "┬"; pub(crate) const LINE_OPEN2: char = '└'; #[derive(Debug, Copy, Clone)] @@ -271,24 +272,26 @@ impl Buffers { pub struct FmtEvent<'a> { pub bufs: &'a mut Buffers, - pub comma: bool, + pub lines: bool, } impl<'a> Visit for FmtEvent<'a> { fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) { let buf = &mut self.bufs.current_buf; - let comma = if self.comma { "," } else { "" }; match field.name() { "message" => { - write!(buf, "{} {:?}", comma, value).unwrap(); - self.comma = true; + write!(buf, " {:?}", value).unwrap(); } // Skip fields that are actually log metadata that have already been handled #[cfg(feature = "tracing-log")] name if name.starts_with("log.") => {} name => { - write!(buf, "{} {}={:?}", comma, name, value).unwrap(); - self.comma = true; + if self.lines { + write!(buf, "\n ").unwrap() + } else { + write!(buf, ", ").unwrap() + } + write!(buf, "{}={:?}", name, value).unwrap(); } } } @@ -338,29 +341,12 @@ fn indent_block_with_lines( if lines.is_empty() { return; - } else if indent_spaces == 0 { - for line in lines { - buf.push_str(prefix); - // The first indent is special, we only need to print open/close and nothing else - if indent == 0 { - match style { - SpanMode::Open { .. } => buf.push_str(LINE_OPEN), - SpanMode::Retrace { .. } => buf.push_str(LINE_OPEN), - SpanMode::Close { .. } => buf.push_str(LINE_CLOSE), - SpanMode::PreOpen { .. } | SpanMode::PostClose => {} - SpanMode::Event => {} - } - } - buf.push_str(line); - buf.push('\n'); - } - return; } let mut s = String::with_capacity(indent_spaces + prefix.len()); s.push_str(prefix); - for _ in 0..(indent_spaces - indent_amount) { + for _ in 0..indent_spaces.saturating_sub(indent_amount) { s.push(' '); } @@ -373,56 +359,132 @@ fn indent_block_with_lines( for _ in 1..(indent_amount / 2) { buf.push_str(LINE_HORIZ); } - buf.push_str(LINE_OPEN); + if lines.len() > 1 { + buf.push_str(ARGS_BRANCH); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push_str(ARGS_BRANCH); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push(' '); + for _ in 0..(indent_amount - 1) { + s.push(' '); + } + } else { + buf.push_str(LINE_OPEN); + } } SpanMode::Open { verbose: false } | SpanMode::Retrace { verbose: false } => { - buf.push(LINE_OPEN2); - for _ in 1..indent_amount { - buf.push_str(LINE_HORIZ); + if indent_spaces != 0 { + buf.push(LINE_OPEN2); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + } + if lines.len() > 1 { + buf.push_str(ARGS_BRANCH); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push_str(ARGS_BRANCH); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push(' '); + + if indent_spaces != 0 { + for _ in 0..indent_amount { + s.push(' '); + } + } + } else { + buf.push_str(LINE_OPEN); } - buf.push_str(LINE_OPEN); } SpanMode::Open { verbose: true } | SpanMode::Retrace { verbose: true } => { - buf.push(' '); - for _ in 1..(indent_amount / 2) { + if indent_spaces != 0 { buf.push(' '); + for _ in 1..(indent_amount / 2) { + buf.push(' '); + } + // We don't have the space for fancy rendering at single space indent. + if indent_amount > 1 { + buf.push(LINE_OPEN2); + } + for _ in (indent_amount / 2)..(indent_amount - 1) { + buf.push_str(LINE_HORIZ); + } } // We don't have the space for fancy rendering at single space indent. if indent_amount > 1 { - buf.push(LINE_OPEN2); - } - for _ in (indent_amount / 2)..(indent_amount - 1) { - buf.push_str(LINE_HORIZ); - } - // We don't have the space for fancy rendering at single space indent. - if indent_amount > 1 { - buf.push_str(LINE_OPEN); + if lines.len() > 1 { + buf.push_str(ARGS_BRANCH); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push_str(ARGS_BRANCH); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push(' '); + if indent_spaces != 0 { + for _ in 0..indent_amount { + s.push(' '); + } + } + } else { + buf.push_str(LINE_OPEN); + } } else { buf.push(' '); } } SpanMode::Close { verbose: false } => { - buf.push(LINE_CLOSE2); - for _ in 1..indent_amount { - buf.push_str(LINE_HORIZ); + if indent_spaces != 0 { + buf.push(LINE_CLOSE2); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } } buf.push_str(LINE_CLOSE); } SpanMode::Close { verbose: true } => { - buf.push(' '); - for _ in 1..(indent_amount / 2) { + if indent_spaces != 0 { buf.push(' '); + for _ in 1..(indent_amount / 2) { + buf.push(' '); + } + // We don't have the space for fancy rendering at single space indent. + if indent_amount > 1 { + buf.push(LINE_CLOSE2); + } + for _ in (indent_amount / 2)..(indent_amount - 1) { + buf.push_str(LINE_HORIZ); + } } // We don't have the space for fancy rendering at single space indent. if indent_amount > 1 { - buf.push(LINE_CLOSE2); - } - for _ in (indent_amount / 2)..(indent_amount - 1) { - buf.push_str(LINE_HORIZ); - } - // We don't have the space for fancy rendering at single space indent. - if indent_amount > 1 { - buf.push_str(LINE_CLOSE); + if lines.len() > 1 { + buf.push('┴'); + for _ in 1..indent_amount - 1 { + buf.push_str(LINE_HORIZ); + } + buf.push('┬'); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push(' '); + + if indent_spaces != 0 { + for _ in 0..indent_amount - 1 { + s.push(' '); + } + } + } else { + buf.push_str(LINE_CLOSE); + } } else { buf.push(' '); } @@ -432,33 +494,75 @@ fn indent_block_with_lines( for _ in 1..(indent_amount / 2) { buf.push_str(LINE_HORIZ); } - buf.push_str(LINE_CLOSE); + if lines.len() > 1 { + buf.push('┴'); + for _ in 1..indent_amount - 1 { + buf.push_str(LINE_HORIZ); + } + buf.push('┬'); + for _ in 1..indent_amount { + buf.push_str(LINE_HORIZ); + } + buf.push(' '); + for _ in 0..indent_amount - 2 { + s.push(' '); + } + } else { + buf.push_str(LINE_CLOSE); + } } SpanMode::Event => { - buf.push_str(LINE_BRANCH); + if indent_spaces != 0 { + buf.push_str(LINE_BRANCH); + } + if lines.len() > 1 { + if indent_spaces != 0 { + for _ in 0..(indent_amount - 1) { + buf.push_str(LINE_HORIZ); + } + } + buf.push_str(ARGS_BRANCH); + } - // add `indent_amount - 1` horizontal lines before the span/event - for _ in 0..(indent_amount - 1) { - buf.push_str(LINE_HORIZ); + if indent_spaces != 0 { + // add `indent_amount - 1` horizontal lines before the span/event + for _ in 0..(indent_amount - 1) { + buf.push_str(LINE_HORIZ); + } } } } buf.push_str(lines[0]); buf.push('\n'); - // add the rest of the indentation, since we don't want to draw horizontal lines - // for subsequent lines - for i in 0..indent_amount { - if i % indent_amount == 0 { - s.push_str(LINE_VERT); - } else { + match style { + SpanMode::Close { verbose: true } if indent_spaces == 0 => { s.push(' '); } + _ => { + // add the rest of the indentation, since we don't want to draw horizontal lines + // for subsequent lines + for i in 0..indent_amount { + if i % indent_amount == 0 { + s.push_str(LINE_VERT); + } else { + s.push(' '); + } + } + } } // add all of the actual content, with each line preceded by the indent string - for line in &lines[1..] { + for (i, line) in lines[1..].iter().enumerate() { buf.push_str(&s); + // Magic number `2` means "last entry" because we iterate from `1` + // and then restart indexing at `0`. + if i == lines.len() - 2 { + buf.push('└'); + } else { + buf.push_str(LINE_BRANCH); + } + buf.push_str(LINE_HORIZ); buf.push_str(line); buf.push('\n'); } diff --git a/src/lib.rs b/src/lib.rs index 0f63430..6ed4f67 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -246,15 +246,22 @@ where V: fmt::Display + 'a, { let mut kvs = kvs.into_iter(); + let (nl, first) = if self.config.bracketed_fields { + ("", "") + } else if self.config.indent_lines { + ("\n ", "\n ") + } else { + (", ", " ") + }; if let Some((k, v)) = kvs.next() { if k == "message" { - write!(buf, "{}", v)?; + write!(buf, " {}", v)?; } else { - write!(buf, "{}={}", k, v)?; + write!(buf, "{first}{}={}", k, v)?; } } for (k, v) in kvs { - write!(buf, ", {}={}", k, v)?; + write!(buf, "{nl}{}={}", k, v)?; } Ok(()) } @@ -372,8 +379,6 @@ where self.styled(Style::new().fg(Color::Green).bold(), "{") // Style::new().fg(Color::Green).dimmed().paint("{") ) .unwrap(); - } else { - write!(current_buf, " ").unwrap(); } self.print_kvs(&mut current_buf, data.kvs.iter().map(|(k, v)| (*k, v))) .unwrap(); @@ -557,7 +562,10 @@ where .expect("Unable to write to buffer"); } - let mut visitor = FmtEvent { comma: false, bufs }; + let mut visitor = FmtEvent { + bufs, + lines: self.config.indent_lines, + }; event.record(&mut visitor); visitor .bufs