diff --git a/Cargo.toml b/Cargo.toml index 7532be4..1eb841e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tracing-tree" -version = "0.3.1" +version = "0.4.0" authors = ["David Barsky ", "Nathan Whitaker", "Oli Scherer "] edition = "2018" license = "MIT OR Apache-2.0" diff --git a/examples/basic.stdout b/examples/basic.stdout index aeb50f4..24f7fdf 100644 --- a/examples/basic.stdout +++ b/examples/basic.stdout @@ -1,41 +1,41 @@ 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 ├─ Xms INFO basic starting -1:main ├─ Xs INFO basic listening +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 ├─ Xms DEBUG basic connected -1:main ├─ Xms DEBUG basic message received, length=2 +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 ├─ Xms DEBUG basic connected +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 ├─ Xms ERROR basic hello +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 ├─ Xms WARN basic weak encryption requested, algo="xor" -1:main ├─ Xms DEBUG basic response sent, length=8 -1:main ├─ Xms DEBUG basic disconnected +1:main ├─ WARN basic weak encryption requested, algo="xor" +1:main ├─ DEBUG basic response sent, 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 ├─ Xms DEBUG basic message received, length=5 -1:main ├─ Xms DEBUG basic response sent, length=8 -1:main ├─ Xms DEBUG basic disconnected +1:main ├─ DEBUG basic message received, length=5 +1:main ├─ DEBUG basic response sent, 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 ├─ Xs WARN basic internal error -1:main ├─ Xs ERROR basic this is a log message -1:main ├─ Xs INFO basic exit +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 diff --git a/examples/basic_non_verbose.stdout b/examples/basic_non_verbose.stdout index a409970..0a02bbc 100644 --- a/examples/basic_non_verbose.stdout +++ b/examples/basic_non_verbose.stdout @@ -1,29 +1,29 @@ 1:main┐basic_non_verbose::hierarchical-example version=0.1 1:main└─┐basic_non_verbose::server host="localhost", port=8080 -1:main ├─ Xms INFO basic_non_verbose starting -1:main ├─ Xs INFO basic_non_verbose listening +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 ├─ Xms DEBUG basic_non_verbose connected -1:main ├─ Xms DEBUG basic_non_verbose message received, length=2 +1:main ├─ DEBUG basic_non_verbose connected +1:main ├─ DEBUG basic_non_verbose message received, length=2 1:main ┌─┘ 1:main └─┐basic_non_verbose::conn peer_addr="8.8.8.8", port=18230 -1:main ├─ Xms DEBUG basic_non_verbose connected +1:main ├─ DEBUG basic_non_verbose connected 1:main ┌─┘ 1:main └─┐basic_non_verbose::foomp 42 <- format string, normal_var=43 -1:main ├─ Xms ERROR basic_non_verbose hello +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 ├─ Xms WARN basic_non_verbose weak encryption requested, algo="xor" -1:main ├─ Xms DEBUG basic_non_verbose response sent, length=8 -1:main ├─ Xms DEBUG basic_non_verbose disconnected +1:main ├─ WARN basic_non_verbose weak encryption requested, algo="xor" +1:main ├─ DEBUG basic_non_verbose response sent, 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 ├─ Xms DEBUG basic_non_verbose message received, length=5 -1:main ├─ Xms DEBUG basic_non_verbose response sent, length=8 -1:main ├─ Xms DEBUG basic_non_verbose disconnected +1:main ├─ DEBUG basic_non_verbose message received, length=5 +1:main ├─ DEBUG basic_non_verbose response sent, length=8 +1:main ├─ DEBUG basic_non_verbose disconnected 1:main ┌─┘ -1:main ├─ Xs WARN basic_non_verbose internal error -1:main ├─ Xs ERROR basic_non_verbose this is a log message -1:main ├─ Xs INFO basic_non_verbose exit +1:main ├─ WARN basic_non_verbose internal error +1:main ├─ ERROR basic_non_verbose this is a log message +1:main ├─ INFO basic_non_verbose exit 1:main┌─┘ 1:main┘ diff --git a/examples/basic_verbose_entry.stdout b/examples/basic_verbose_entry.stdout index f5d38f2..f85badf 100644 --- a/examples/basic_verbose_entry.stdout +++ b/examples/basic_verbose_entry.stdout @@ -1,35 +1,35 @@ 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 ├─ Xms INFO basic_verbose_entry starting -1:main ├─ Xs INFO basic_verbose_entry listening +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 ├─ Xms DEBUG basic_verbose_entry connected -1:main ├─ Xms DEBUG basic_verbose_entry message received, length=2 +1:main ├─ DEBUG basic_verbose_entry connected +1:main ├─ DEBUG basic_verbose_entry message received, 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 ├─ Xms DEBUG basic_verbose_entry connected +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 ├─ Xms ERROR basic_verbose_entry hello +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 ├─ Xms WARN basic_verbose_entry weak encryption requested, algo="xor" -1:main ├─ Xms DEBUG basic_verbose_entry response sent, length=8 -1:main ├─ Xms DEBUG basic_verbose_entry disconnected +1:main ├─ WARN basic_verbose_entry weak encryption requested, algo="xor" +1:main ├─ DEBUG basic_verbose_entry response sent, 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 ├─ Xms DEBUG basic_verbose_entry message received, length=5 -1:main ├─ Xms DEBUG basic_verbose_entry response sent, length=8 -1:main ├─ Xms DEBUG basic_verbose_entry disconnected +1:main ├─ DEBUG basic_verbose_entry message received, length=5 +1:main ├─ DEBUG basic_verbose_entry response sent, length=8 +1:main ├─ DEBUG basic_verbose_entry disconnected 1:main ┌─┘ -1:main ├─ Xs WARN basic_verbose_entry internal error -1:main ├─ Xs ERROR basic_verbose_entry this is a log message -1:main ├─ Xs INFO basic_verbose_entry exit +1:main ├─ WARN basic_verbose_entry internal error +1:main ├─ ERROR basic_verbose_entry this is a log message +1:main ├─ INFO basic_verbose_entry exit 1:main┌─┘ 1:main┘ diff --git a/examples/basic_verbose_exit.stdout b/examples/basic_verbose_exit.stdout index 020f738..fbfada3 100644 --- a/examples/basic_verbose_exit.stdout +++ b/examples/basic_verbose_exit.stdout @@ -1,35 +1,35 @@ 1:main┐basic_verbose_exit::hierarchical-example version=0.1 1:main└─┐basic_verbose_exit::server host="localhost", port=8080 -1:main ├─ Xms INFO basic_verbose_exit starting -1:main ├─ Xs INFO basic_verbose_exit listening +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 ├─ Xms DEBUG basic_verbose_exit connected -1:main ├─ Xms DEBUG basic_verbose_exit message received, length=2 +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 ├─ Xms DEBUG basic_verbose_exit connected +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 ├─ Xms ERROR basic_verbose_exit hello +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 ├─ Xms WARN basic_verbose_exit weak encryption requested, algo="xor" -1:main ├─ Xms DEBUG basic_verbose_exit response sent, length=8 -1:main ├─ Xms DEBUG basic_verbose_exit disconnected +1:main ├─ WARN basic_verbose_exit weak encryption requested, algo="xor" +1:main ├─ DEBUG basic_verbose_exit response sent, 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 ├─ Xms DEBUG basic_verbose_exit message received, length=5 -1:main ├─ Xms DEBUG basic_verbose_exit response sent, length=8 -1:main ├─ Xms DEBUG basic_verbose_exit disconnected +1:main ├─ DEBUG basic_verbose_exit message received, length=5 +1:main ├─ DEBUG basic_verbose_exit response sent, 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 ├─ Xs WARN basic_verbose_exit internal error -1:main ├─ Xs ERROR basic_verbose_exit this is a log message -1:main ├─ Xs INFO basic_verbose_exit exit +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 diff --git a/examples/concurrent.stdout b/examples/concurrent.stdout index 92cfe79..6429b68 100644 --- a/examples/concurrent.stdout +++ b/examples/concurrent.stdout @@ -1,25 +1,25 @@ 1:main┐concurrent::hierarchical-example version=0.1 1:main└───┐concurrent::server host="localhost", port=8080 -1:main ├─── Xms INFO concurrent starting -1:main ├─── Xs INFO concurrent listening -1:main ├─── Xs DEBUG concurrent starting countdowns +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 ├─── Xms DEBUG concurrent polling countdown, label="a", count=3 +1:main ├─── DEBUG concurrent polling countdown, label="a", count=3 1:main └───┐concurrent::countdown_b -1:main ├─── Xms DEBUG concurrent polling countdown, label="b", count=5 -1:main ├─── Xms DEBUG concurrent polling countdown, label="b", count=4 +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 ├─── Xms DEBUG concurrent polling countdown, label="a", count=2 +1:main ├─── DEBUG concurrent polling countdown, label="a", count=2 1:main └───┐concurrent::conn peer_addr="82.9.9.9", port=42381 -1:main ├─── Xms WARN concurrent peer1 warning +1:main ├─── WARN concurrent peer1 warning 1:main └───┐concurrent::countdowns -1:main ├─── Xms INFO concurrent finished polling countdowns +1:main ├─── INFO concurrent finished polling countdowns 1:main ┌───┘ 1:main ┌───┘ 1:main ┌───┘ 1:main ┌───┘ -1:main ├─── Xs INFO concurrent all done! -1:main ├─── Xs INFO concurrent exit +1:main ├─── INFO concurrent all done! +1:main ├─── INFO concurrent exit 1:main┌───┘ 1:main┘ diff --git a/examples/concurrent_eager.stdout b/examples/concurrent_eager.stdout index a4551d0..d8d9411 100644 --- a/examples/concurrent_eager.stdout +++ b/examples/concurrent_eager.stdout @@ -6,11 +6,11 @@ 1:main└───┐concurrent_eager::b 1:main┐concurrent_eager::spawn_fut key="a" 1:main└───┐concurrent_eager::a -1:main ├─── Xms INFO 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 ├─── Xms INFO concurrent_eager b +1:main ├─── INFO concurrent_eager b 1:main┌───┘ 1:main┘ 1:main┘ diff --git a/examples/concurrent_verbose.stdout b/examples/concurrent_verbose.stdout index 8f1e3ce..d2ea058 100644 --- a/examples/concurrent_verbose.stdout +++ b/examples/concurrent_verbose.stdout @@ -1,25 +1,25 @@ 1:main┐concurrent_verbose::hierarchical-example version=0.1 1:main└───┐concurrent_verbose::server host="localhost", port=8080 -1:main ├─── Xms INFO concurrent_verbose starting -1:main ├─── Xs INFO concurrent_verbose listening -1:main ├─── Xs DEBUG concurrent_verbose starting countdowns +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 ├─── Xms DEBUG concurrent_verbose polling countdown, label="a", count=3 +1:main ├─── DEBUG concurrent_verbose polling countdown, label="a", count=3 1:main └─┐concurrent_verbose::countdowns 1:main └─┐concurrent_verbose::countdown_b -1:main ├─── Xms DEBUG concurrent_verbose polling countdown, label="b", count=5 -1:main ├─── Xms DEBUG concurrent_verbose polling countdown, label="b", count=4 +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 ├─── Xms DEBUG concurrent_verbose polling countdown, label="a", count=2 +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 ├─── Xms WARN concurrent_verbose peer1 warning +1:main ├─── WARN concurrent_verbose peer1 warning 1:main └─┐concurrent_verbose::server host="localhost", port=8080 1:main └─┐concurrent_verbose::countdowns -1:main ├─── Xms INFO concurrent_verbose finished polling 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 @@ -28,8 +28,8 @@ 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 ├─── Xs INFO concurrent_verbose all done! -1:main ├─── Xs INFO concurrent_verbose exit +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 diff --git a/examples/deferred.stdout b/examples/deferred.stdout index 90c17e2..e5335b9 100644 --- a/examples/deferred.stdout +++ b/examples/deferred.stdout @@ -1,45 +1,45 @@ -> 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 ├─ Xms INFO deferred starting -1:main ├─ Xs INFO deferred listening +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 ├─ Xms DEBUG deferred connected, peer="peer1" -1:main ├─ Xms DEBUG deferred message received, length=2 +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 ├─ Xms DEBUG deferred connected, peer="peer3" +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 ├─ Xms ERROR deferred hello +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 ├─ Xms WARN deferred weak encryption requested, algo="xor" -1:main ├─ Xms DEBUG deferred response sent, length=8 -1:main ├─ Xms DEBUG deferred disconnected +1:main ├─ WARN deferred weak encryption requested, algo="xor" +1:main ├─ DEBUG deferred response sent, 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 ├─ Xms DEBUG deferred message received, length=5 -1:main ├─ Xms DEBUG deferred response sent, length=8 -1:main ├─ Xms DEBUG deferred disconnected +1:main ├─ DEBUG deferred message received, length=5 +1:main ├─ DEBUG deferred response sent, 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 ├─ Xs WARN deferred internal error -1:main ├─ Xs ERROR deferred this is a log message -1:main ├─ Xs INFO deferred exit +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 diff --git a/examples/no-indent.stdout b/examples/no-indent.stdout index a06c3aa..21bd888 100644 --- a/examples/no-indent.stdout +++ b/examples/no-indent.stdout @@ -1,21 +1,21 @@ 1:main no_indent::hierarchical-example version=0.1 1:main no_indent::server host="localhost", port=8080 -1:main Xms INFO no_indent starting -1:main Xms INFO no_indent listening +1:main INFO no_indent starting +1:main INFO no_indent listening 1:main no_indent::conn peer_addr="82.9.9.9", port=42381 -1:main Xms DEBUG no_indent connected -1:main Xms DEBUG no_indent message received, length=2 +1:main DEBUG no_indent connected +1:main DEBUG no_indent message received, length=2 1:main no_indent::conn peer_addr="8.8.8.8", port=18230 -1:main Xms DEBUG no_indent connected +1:main DEBUG no_indent connected 1:main no_indent::foomp 42 <- format string, normal_var=43 -1:main Xms ERROR no_indent hello +1:main ERROR no_indent hello 1:main no_indent::conn peer_addr="82.9.9.9", port=42381 -1:main Xms WARN no_indent weak encryption requested, algo="xor" -1:main Xms DEBUG no_indent response sent, length=8 -1:main Xms DEBUG no_indent disconnected +1:main WARN no_indent weak encryption requested, algo="xor" +1:main DEBUG no_indent response sent, length=8 +1:main DEBUG no_indent disconnected 1:main no_indent::conn peer_addr="8.8.8.8", port=18230 -1:main Xms DEBUG no_indent message received, length=5 -1:main Xms DEBUG no_indent response sent, length=8 -1:main Xms DEBUG no_indent disconnected -1:main Xs WARN no_indent internal error -1:main Xs INFO no_indent exit +1:main DEBUG no_indent message received, length=5 +1:main DEBUG no_indent response sent, length=8 +1:main DEBUG no_indent disconnected +1:main WARN no_indent internal error +1:main INFO no_indent exit diff --git a/examples/quiet.stdout b/examples/quiet.stdout index f6610bf..5eddea7 100644 --- a/examples/quiet.stdout +++ b/examples/quiet.stdout @@ -1,28 +1,28 @@ 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 ├─ INFO quiet starting +1:main ├─ 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 ├─ DEBUG quiet connected +1:main ├─ 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 ├─ DEBUG quiet connected 1:main ┌─┘ 1:main └─┐quiet::foomp 42 <- format string, normal_var=43 -1:main ├─ Xms ERROR quiet hello +1:main ├─ 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 ├─ WARN quiet weak encryption requested, algo="xor" +1:main ├─ DEBUG quiet response sent, length=8 +1:main ├─ 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 ├─ DEBUG quiet message received, length=5 +1:main ├─ DEBUG quiet response sent, length=8 +1:main ├─ DEBUG quiet disconnected 1:main ┌─┘ -1:main ├─ Xs WARN quiet internal error -1:main ├─ Xs INFO quiet exit +1:main ├─ WARN quiet internal error +1:main ├─ INFO quiet exit 1:main┌─┘ 1:main┘ diff --git a/examples/stderr.stderr b/examples/stderr.stderr index 03d7c5c..6763051 100644 --- a/examples/stderr.stderr +++ b/examples/stderr.stderr @@ -1,109 +1,109 @@ ┐fibonacci_seq{to=5} -├─ Xms DEBUG Pushing 0 fibonacci +├─ DEBUG Pushing 0 fibonacci └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ -├─ Xms DEBUG Pushing 1 fibonacci +├─ DEBUG Pushing 1 fibonacci └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ -├─ Xms DEBUG Pushing 2 fibonacci +├─ DEBUG Pushing 2 fibonacci └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ -├─ Xms DEBUG Pushing 3 fibonacci +├─ DEBUG Pushing 3 fibonacci └─┐nth_fibonacci{n=3} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ -├─ Xms DEBUG Pushing 4 fibonacci +├─ DEBUG Pushing 4 fibonacci └─┐nth_fibonacci{n=4} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=3} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ ┌─┘ -├─ Xms DEBUG Pushing 5 fibonacci +├─ DEBUG Pushing 5 fibonacci └─┐nth_fibonacci{n=5} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=4} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=3} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ ┌─┘ └─┐nth_fibonacci{n=3} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=2} - ├─ Xms DEBUG Recursing + ├─ DEBUG Recursing └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ └─┐nth_fibonacci{n=0} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ └─┐nth_fibonacci{n=1} - ├─ Xms DEBUG Base case + ├─ DEBUG Base case ┌─┘ ┌─┘ ┌─┘ diff --git a/examples/wraparound.stdout b/examples/wraparound.stdout index e254eae..8f9c67d 100644 --- a/examples/wraparound.stdout +++ b/examples/wraparound.stdout @@ -1,96 +1,96 @@ 1:main┐wraparound::recurse i=0 -1:main├─ Xms WARN wraparound boop +1:main├─ WARN wraparound boop 1:main└─┐wraparound::recurse i=1 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=2 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=3 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=4 1:main────────┘ -1:main Xms WARN wraparound boop +1:main WARN wraparound boop 1:main┐wraparound::recurse i=5 -1:main├─ Xms WARN wraparound boop +1:main├─ WARN wraparound boop 1:main└─┐wraparound::recurse i=6 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=7 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=8 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=9 1:main────────┘ -1:main Xms WARN wraparound boop +1:main WARN wraparound boop 1:main┐wraparound::recurse i=10 -1:main├─ Xms WARN wraparound boop +1:main├─ WARN wraparound boop 1:main└─┐wraparound::recurse i=11 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=12 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=13 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=14 1:main────────┘ -1:main Xms WARN wraparound boop +1:main WARN wraparound boop 1:main┐wraparound::recurse i=15 -1:main├─ Xms WARN wraparound boop +1:main├─ WARN wraparound boop 1:main└─┐wraparound::recurse i=16 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=17 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=18 -1:main ├─ Xms WARN wraparound boop +1:main ├─ WARN wraparound boop 1:main └─┐wraparound::recurse i=19 1:main────────┘ -1:main Xms WARN wraparound boop +1:main WARN wraparound boop 1:main┐wraparound::recurse i=20 -1:main├─ Xms WARN wraparound boop +1:main├─ WARN wraparound boop 1:main└─┐wraparound::recurse i=21 -1:main ├─ Xms WARN wraparound boop -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound boop +1:main ├─ WARN wraparound bop 1:main┌─┘ -1:main├─ Xms WARN wraparound bop +1:main├─ WARN wraparound bop 1:main┘ -1:main Xms WARN wraparound bop +1:main WARN wraparound bop 1:main────────┐ 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main┌─┘ -1:main├─ Xms WARN wraparound bop +1:main├─ WARN wraparound bop 1:main┘ -1:main Xms WARN wraparound bop +1:main WARN wraparound bop 1:main────────┐ 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main┌─┘ -1:main├─ Xms WARN wraparound bop +1:main├─ WARN wraparound bop 1:main┘ -1:main Xms WARN wraparound bop +1:main WARN wraparound bop 1:main────────┐ 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main┌─┘ -1:main├─ Xms WARN wraparound bop +1:main├─ WARN wraparound bop 1:main┘ -1:main Xms WARN wraparound bop +1:main WARN wraparound bop 1:main────────┐ 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main ┌─┘ -1:main ├─ Xms WARN wraparound bop +1:main ├─ WARN wraparound bop 1:main┌─┘ -1:main├─ Xms WARN wraparound bop +1:main├─ WARN wraparound bop 1:main┘ diff --git a/src/format.rs b/src/format.rs index 1ab6786..84b904b 100644 --- a/src/format.rs +++ b/src/format.rs @@ -62,8 +62,6 @@ pub struct Config { pub deferred_spans: bool, /// Print a label of the span mode (open/close etc). pub span_modes: bool, - /// Whether to print the time with higher precision. - pub higher_precision: bool, } impl Config { @@ -142,13 +140,6 @@ impl Config { } } - pub fn with_higher_precision(self, higher_precision: bool) -> Self { - Self { - higher_precision, - ..self - } - } - pub(crate) fn prefix(&self) -> String { let mut buf = String::new(); if self.render_thread_ids { @@ -188,7 +179,6 @@ impl Default for Config { bracketed_fields: false, deferred_spans: false, span_modes: false, - higher_precision: false, } } } diff --git a/src/lib.rs b/src/lib.rs index e10dcab..0f63430 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -236,20 +236,8 @@ where } } - /// Whether to print the time with higher precision. - pub fn with_higher_precision(self, higher_precision: bool) -> Self { - Self { - config: self.config.with_higher_precision(higher_precision), - ..self - } - } - fn styled(&self, style: Style, text: impl AsRef) -> String { - if self.config.ansi { - style.paint(text.as_ref()).to_string() - } else { - text.as_ref().to_string() - } + styled(self.config.ansi, style, text) } fn print_kvs<'a, I, V>(&self, buf: &mut impl fmt::Write, kvs: I) -> fmt::Result @@ -404,7 +392,7 @@ where bufs.flush_current_buf(writer) } - fn get_timestamp(&self, span: SpanRef) -> Option + fn write_timestamp(&self, span: SpanRef, buf: &mut String) where S: Subscriber + for<'span> LookupSpan<'span>, { @@ -413,59 +401,9 @@ where .get::() .expect("Data cannot be found in extensions"); - if self.config.higher_precision { - Some(self.format_timestamp_with_decimals(data.start)) - } else { - Some(self.format_timestamp(data.start)) - } - } - - fn format_timestamp(&self, start: std::time::Instant) -> String { - let elapsed = start.elapsed(); - let millis = elapsed.as_millis(); - let secs = elapsed.as_secs(); - - // Convert elapsed time to appropriate units: ms, s, or m. - // - Less than 1s : use ms - // - Less than 1m : use s - // - 1m and above : use m - let (n, unit) = if millis < 1000 { - (millis as _, "ms") - } else if secs < 60 { - (secs, "s ") - } else { - (secs / 60, "m ") - }; - - let timestamp = format!("{n:>3}"); - self.style_timestamp(timestamp, unit) - } - - fn format_timestamp_with_decimals(&self, start: std::time::Instant) -> String { - let secs = start.elapsed().as_secs_f64(); - - // Convert elapsed time to appropriate units: μs, ms, or s. - // - Less than 1ms: use μs - // - Less than 1s : use ms - // - 1s and above : use s - let (n, unit) = if secs < 0.001 { - (secs * 1_000_000.0, "μs") - } else if secs < 1.0 { - (secs * 1_000.0, "ms") - } else { - (secs, "s ") - }; - - let timestamp = format!(" {n:.2}"); - self.style_timestamp(timestamp, unit) - } - - fn style_timestamp(&self, timestamp: String, unit: &str) -> String { - format!( - "{timestamp}{unit} ", - timestamp = self.styled(Style::new().dimmed(), timestamp), - unit = self.styled(Style::new().dimmed(), unit), - ) + self.timer + .style_timestamp(self.config.ansi, data.start.elapsed(), buf) + .unwrap() } fn is_recursive() -> Option { @@ -482,6 +420,14 @@ where } } +fn styled(ansi: bool, style: Style, text: impl AsRef) -> String { + if ansi { + style.paint(text.as_ref()).to_string() + } else { + text.as_ref().to_string() + } +} + struct RecursiveGuard(&'static LocalKey); impl Drop for RecursiveGuard { @@ -581,9 +527,8 @@ where // check if this event occurred in the context of a span. // if it has, get the start time of this span. if let Some(span) = span { - if let Some(timestamp) = self.get_timestamp(span) { - write!(&mut event_buf, "{}", timestamp).expect("Unable to write to buffer"); - } + self.write_timestamp(span, event_buf); + event_buf.push(' '); } #[cfg(feature = "tracing-log")] diff --git a/src/time.rs b/src/time.rs index e0f81d4..3dc85f8 100644 --- a/src/time.rs +++ b/src/time.rs @@ -1,3 +1,9 @@ +use std::{fmt::Write, time::Duration}; + +use nu_ansi_term::Style; + +use crate::styled; + /// A type that can measure and format the current time. /// /// This trait is used by [HierarchicalLayer] to include a timestamp with each @@ -21,6 +27,12 @@ // since it doesn't have a public constructor. pub trait FormatTime { fn format_time(&self, w: &mut impl std::fmt::Write) -> std::fmt::Result; + fn style_timestamp( + &self, + ansi: bool, + elapsed: Duration, + w: &mut impl std::fmt::Write, + ) -> std::fmt::Result; } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -30,6 +42,14 @@ impl FormatTime for () { fn format_time(&self, _w: &mut impl std::fmt::Write) -> std::fmt::Result { Ok(()) } + fn style_timestamp( + &self, + _ansi: bool, + _elapsed: Duration, + _w: &mut impl std::fmt::Write, + ) -> std::fmt::Result { + Ok(()) + } } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -37,7 +57,10 @@ impl FormatTime for () { /// Retrieve and print the current wall-clock time in UTC timezone. #[cfg(feature = "time")] #[derive(Debug, Clone, Copy, Eq, PartialEq, Default)] -pub struct UtcDateTime; +pub struct UtcDateTime { + /// Whether to print the time with higher precision. + pub higher_precision: bool, +} #[cfg(feature = "time")] impl FormatTime for UtcDateTime { @@ -45,6 +68,15 @@ impl FormatTime for UtcDateTime { let time = time::OffsetDateTime::now_utc(); write!(w, "{} {}", time.date(), time.time()) } + + fn style_timestamp( + &self, + ansi: bool, + elapsed: Duration, + w: &mut impl std::fmt::Write, + ) -> std::fmt::Result { + style_timestamp(ansi, self.higher_precision, elapsed, w) + } } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -61,7 +93,10 @@ impl FormatTime for UtcDateTime { // private `datetime` module to format the actual time. #[cfg(feature = "time")] #[derive(Debug, Clone, Copy, Eq, PartialEq, Default)] -pub struct LocalDateTime; +pub struct LocalDateTime { + /// Whether to print the time with higher precision. + pub higher_precision: bool, +} #[cfg(feature = "time")] impl FormatTime for LocalDateTime { @@ -69,6 +104,14 @@ impl FormatTime for LocalDateTime { let time = time::OffsetDateTime::now_local().expect("time offset cannot be determined"); write!(w, "{}", time) } + fn style_timestamp( + &self, + ansi: bool, + elapsed: Duration, + w: &mut impl std::fmt::Write, + ) -> std::fmt::Result { + style_timestamp(ansi, self.higher_precision, elapsed, w) + } } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -80,19 +123,22 @@ impl FormatTime for LocalDateTime { #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct Uptime { epoch: std::time::Instant, + /// Whether to print the time with higher precision. + pub higher_precision: bool, } impl Default for Uptime { fn default() -> Self { - Uptime { - epoch: std::time::Instant::now(), - } + Uptime::from(std::time::Instant::now()) } } impl From for Uptime { fn from(epoch: std::time::Instant) -> Self { - Uptime { epoch } + Uptime { + epoch, + higher_precision: false, + } } } @@ -101,6 +147,84 @@ impl FormatTime for Uptime { let e = self.epoch.elapsed(); write!(w, "{:4}.{:06}s", e.as_secs(), e.subsec_micros()) } + fn style_timestamp( + &self, + ansi: bool, + elapsed: Duration, + w: &mut impl std::fmt::Write, + ) -> std::fmt::Result { + style_timestamp(ansi, self.higher_precision, elapsed, w) + } +} + +fn style_timestamp( + ansi: bool, + higher_precision: bool, + elapsed: Duration, + w: &mut impl Write, +) -> std::fmt::Result { + if higher_precision { + format_timestamp_with_decimals(ansi, elapsed, w) + } else { + format_timestamp(ansi, elapsed, w) + } +} + +fn format_timestamp(ansi: bool, elapsed: Duration, w: &mut impl Write) -> std::fmt::Result { + let millis = elapsed.as_millis(); + let secs = elapsed.as_secs(); + + // Convert elapsed time to appropriate units: ms, s, or m. + // - Less than 1s : use ms + // - Less than 1m : use s + // - 1m and above : use m + let (n, unit) = if millis < 1000 { + (millis as _, "ms") + } else if secs < 60 { + (secs, "s ") + } else { + (secs / 60, "m ") + }; + + let timestamp = format!("{n:>3}"); + write_style_timestamp(ansi, timestamp, unit, w) +} + +fn format_timestamp_with_decimals( + ansi: bool, + elapsed: Duration, + w: &mut impl Write, +) -> std::fmt::Result { + let secs = elapsed.as_secs_f64(); + + // Convert elapsed time to appropriate units: μs, ms, or s. + // - Less than 1ms: use μs + // - Less than 1s : use ms + // - 1s and above : use s + let (n, unit) = if secs < 0.001 { + (secs * 1_000_000.0, "μs") + } else if secs < 1.0 { + (secs * 1_000.0, "ms") + } else { + (secs, "s ") + }; + + let timestamp = format!(" {n:.2}"); + write_style_timestamp(ansi, timestamp, unit, w) +} + +fn write_style_timestamp( + ansi: bool, + timestamp: String, + unit: &str, + w: &mut impl Write, +) -> std::fmt::Result { + write!( + w, + "{timestamp}{unit}", + timestamp = styled(ansi, Style::new().dimmed(), timestamp), + unit = styled(ansi, Style::new().dimmed(), unit), + ) } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -110,7 +234,15 @@ where F: FormatTime, { fn format_time(&self, w: &mut impl std::fmt::Write) -> std::fmt::Result { - (*self).format_time(w) + F::format_time(self, w) + } + fn style_timestamp( + &self, + ansi: bool, + duration: Duration, + w: &mut impl std::fmt::Write, + ) -> std::fmt::Result { + F::style_timestamp(self, ansi, duration, w) } } diff --git a/test_dependencies/Cargo.lock b/test_dependencies/Cargo.lock index b9c6b1a..76a7f78 100644 --- a/test_dependencies/Cargo.lock +++ b/test_dependencies/Cargo.lock @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "tracing-tree" -version = "0.3.1" +version = "0.4.0" dependencies = [ "nu-ansi-term", "tracing-core", diff --git a/tests/format_time.rs b/tests/format_time.rs index b24b166..673dac5 100644 --- a/tests/format_time.rs +++ b/tests/format_time.rs @@ -19,6 +19,14 @@ impl FormatTime for FormatTimeCounter { self.0.fetch_add(1, Ordering::Relaxed); Ok(()) } + fn style_timestamp( + &self, + _ansi: bool, + _elapsed: std::time::Duration, + _w: &mut impl std::fmt::Write, + ) -> std::fmt::Result { + Ok(()) + } } #[test] diff --git a/tests/ui.rs b/tests/ui.rs index cca8241..a521c0d 100644 --- a/tests/ui.rs +++ b/tests/ui.rs @@ -8,12 +8,6 @@ fn main() -> Result<()> { config.args.push("feature=\"tracing-log\"".into()); config.out_dir = Some("target/ui_test".into()); config.mode = Mode::Run { exit_code: 0 }; - config.stdout_filter("[0-9]{3}(ms|s|m)", " X$1"); - config.stdout_filter("[0-9]{2}(ms|s|m)", " X$1"); - config.stdout_filter("[0-9]{1}(ms|s|m)", "X$1"); - config.stderr_filter("[0-9]{3}(ms|s|m)", " X$1"); - config.stderr_filter("[0-9]{2}(ms|s|m)", " X$1"); - config.stderr_filter("[0-9]{1}(ms|s|m)", "X$1"); config.output_conflict_handling = if std::env::args().any(|arg| arg == "--bless") { OutputConflictHandling::Bless } else {