Skip to content

Commit 73466c2

Browse files
author
Oliver Scherer
committed
Add tracing-log to test
1 parent 1ac8754 commit 73466c2

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ termcolor = "1.0.5"
1515
ansi_term = "0.12.1"
1616
chrono = "0.4.10"
1717
atty = "0.2.14"
18+
tracing-log = { version = "0.1", optional = true }
19+
20+
[features]
21+
default = ["tracing-log"]
1822

1923
[dev-dependencies]
2024
glob = "0.3.0"
2125
assert_cmd = "1.0.1"
26+
log = "0.4.11"
2227

2328
[[test]]
2429
name = "ui"

examples/basic.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ fn main() {
1414

1515
let subscriber = Registry::default().with(layer);
1616
tracing::subscriber::set_global_default(subscriber).unwrap();
17+
#[cfg(feature = "tracing-log")]
18+
tracing_log::LogTracer::init().unwrap();
1719

1820
let app_span = span!(Level::TRACE, "hierarchical-example", version = %0.1);
1921
let _e = app_span.enter();
@@ -57,6 +59,7 @@ fn main() {
5759
debug!("disconnected");
5860
});
5961
warn!("internal error");
62+
log::error!("this is a log message");
6063
info!("exit");
6164
}
6265

examples/basic.stdout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
1:main│ │┌┘basic::conn peer_addr="8.8.8.8", port=18230
3535
1:main│ ├┘basic::server host="localhost", port=8080
3636
1:main│ ├─ms WARN basic internal error
37+
1:main│ ├─ms ERROR log this is a log message, log.target="basic", log.module_path="basic", log.file="examples/basic.rs", log.line=63
3738
1:main│ ├─ms INFO basic exit
3839
1:main│┌┘basic::server host="localhost", port=8080
3940
1:main├┘basic::hierarchical-example version=0.1

0 commit comments

Comments
 (0)