Skip to content

Commit 44fc198

Browse files
committed
Emit tracing output to stderr
Behavior of the crate differs between the log and tracing backends: while log defaults to printing messages to stderr, tracing emits them to stdout. Until version 0.3.19 the tracing-subscriber crate did not allow changing this default. Pull request #3187 [0] changed that and release 0.3.20 contains this logic. Now that we can, adjust the tracing based backend to log to stderr for consistency. [0] tokio-rs/tracing#3187
1 parent 7fc5975 commit 44fc198

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ unstable = ["test-log-macros/unstable"]
7878

7979
[dependencies]
8080
test-log-macros = {version = "0.2.18", path = "macros"}
81-
tracing-subscriber = {version = "0.3.17", default-features = false, optional = true, features = ["env-filter", "fmt"]}
81+
tracing-subscriber = {version = "0.3.20", default-features = false, optional = true, features = ["env-filter", "fmt"]}
8282
env_logger = {version = "0.11", default-features = false, optional = true}
8383

8484
[dev-dependencies]

macros/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ fn expand_logging_init(attribute_args: &AttributeArgs) -> Tokens {
208208
::test_log::env_logger::Env::default()
209209
.default_filter_or(#default_filter)
210210
)
211+
.target(::test_log::env_logger::Target::Stderr)
211212
.is_test(true)
212213
.try_init();
213214
}
@@ -274,7 +275,7 @@ fn expand_tracing_init(attribute_args: &AttributeArgs) -> Tokens {
274275
let _ = ::test_log::tracing_subscriber::FmtSubscriber::builder()
275276
.with_env_filter(#env_filter)
276277
.with_span_events(__internal_event_filter)
277-
.with_test_writer()
278+
.with_writer(::test_log::tracing_subscriber::fmt::TestWriter::with_stderr)
278279
.try_init();
279280
}
280281
}

0 commit comments

Comments
 (0)