tracing-serde: Use path deps to tracing-core and tracing. (#130)

This addresses a TODO in the `Cargo.toml`.
This commit is contained in:
Bruce Mitchener 2019-07-01 11:40:27 +07:00 committed by Eliza Weisman
parent ce37de8982
commit 2649a7bab4
2 changed files with 16 additions and 24 deletions

View File

@ -6,16 +6,8 @@ license = "MIT"
[dependencies]
serde = "1"
[dependencies.tracing-core]
# TODO: replace this with a path dependency on the local `tracing-core`.
package = "tokio-trace-core"
version = "0.2.0"
tracing-core = { version = "0.1", path = "../tracing-core" }
[dev-dependencies]
serde_json = "1.0"
[dev-dependencies.tracing]
# TODO: replace this with a path dependency on the local `tracing`.
package = "tokio-trace"
version = "0.1"
tracing = { version = "0.1", path = "../tracing" }

View File

@ -85,19 +85,19 @@ impl Subscriber for JsonSubscriber {
}
fn shave(yak: usize) -> bool {
span!(Level::TRACE, "shave", yak = yak).enter(|| {
debug!(
message = "hello! I'm gonna shave a yak.",
excitement = "yay!"
);
if yak == 3 {
warn!(target: "yak_events", "could not locate yak!");
false
} else {
trace!(target: "yak_events", "yak shaved successfully");
true
}
})
let span = span!(Level::TRACE, "shave", yak = yak);
let _e = span.enter();
debug!(
message = "hello! I'm gonna shave a yak.",
excitement = "yay!"
);
if yak == 3 {
warn!(target: "yak_events", "could not locate yak!");
false
} else {
trace!(target: "yak_events", "yak shaved successfully");
true
}
}
fn main() {
@ -110,7 +110,7 @@ fn main() {
let mut number_shaved = 0;
debug!("preparing to shave {} yaks", number_of_yaks);
span!(Level::TRACE, "shaving_yaks", yaks_to_shave = number_of_yaks).enter(|| {
span!(Level::TRACE, "shaving_yaks", yaks_to_shave = number_of_yaks).in_scope(|| {
info!("shaving yaks");
for yak in 1..=number_of_yaks {