From 3677ec62105557ea4e56bc75ce4e501c22dd8058 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Wed, 26 Aug 2026 13:28:59 +0000 Subject: [PATCH] examples: Log line numbers in the transfer example (#4485) ## Description This makes reading logfiles so much more pleasant. ## Breaking Changes This is an example: none. ## Notes & open questions n/a ## Change checklist - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] Tests if relevant. - [x] All breaking changes documented. - [x] This PR was created by a human that thought critically about the proposed change and wrote an as clear and concise description as they could. - [x] This PR isn't slop, and is carefully crafted to do have the intented effect. --- iroh/examples/transfer.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iroh/examples/transfer.rs b/iroh/examples/transfer.rs index bf26c80fd3..061081ed6e 100644 --- a/iroh/examples/transfer.rs +++ b/iroh/examples/transfer.rs @@ -1346,18 +1346,18 @@ mod duration_micros { } pub fn init_tracing(path: Option<&Path>) { - use tracing_subscriber::{fmt, registry}; + let layer = tracing_subscriber::fmt::layer().with_line_number(true); if let Some(path) = path { let file = File::create(path).expect("failed to create trace log file"); let filter = EnvFilter::try_from_default_env() .unwrap_or_else(|_| EnvFilter::new("iroh=trace,transfer=trace,noq=trace")); - let layer = fmt::layer().with_writer(file).with_filter(filter); - registry().with(layer).init() + let layer = layer.with_writer(file).with_filter(filter); + tracing_subscriber::registry().with(layer).init() } else { - let layer = fmt::layer() + let layer = layer .with_writer(std::io::stderr) .with_filter(EnvFilter::from_default_env()); - registry().with(layer).init() + tracing_subscriber::registry().with(layer).init() } }