Skip to content

Commit 08b0b8a

Browse files
authored
examples(iroh): add --logs and --mode ping features to transfer example (#3893)
## Description More improvements to our `transport` example to ease dogfooding: * new `--logs` flag (for both provide and fetch) for simple file logging: - without further config, creates a directory `./logs/transfer-{cmd}-{date}-{endpoint_id}` and saves logs with `iroh=trace,transfer=trace` to a `logs` file in that directory. - different log level can be set with RUST_LOG - different path can be set with `--logs-path` - qlog files are also written to that directory if the `qlog` feature is enabled * New `--mode ping` option for `fetch` command: instead of transferring as much data as possible, this just keeps the connection open until the `--duration` is expired (default: 10s). This gives much smaller log files (both tracing and qlog) so easier to debug when looking for connection changes only. * Regular output now includes the time since start after each line. Useful to interpret the "switched to direct" etc lines after the fact (they didn't have any time indication so far) * Better formatting for durations * Better spans on accept side. Each connection gets an `id` now that easily allows to grep for that connection through both iroh and quinn logs * Print path ids with the paths stats and changes. This allows to correlate with the tracing logs now. With both logs and qlog in a single dir it's now really straightforward to share it eg with sendme. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions Should `--logs` include `iroh_quinn=trace` by default or not? ## Change checklist <!-- Remove any that are not relevant. --> - [ ] Self-review. - [ ] 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. - [ ] Tests if relevant. - [ ] All breaking changes documented. - [ ] List all breaking changes in the above "Breaking Changes" section. - [ ] Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are: - [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc) - [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip) - [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs) - [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe) - [ ] [`sendme`](https://github.com/n0-computer/sendme)
1 parent aa14381 commit 08b0b8a

7 files changed

Lines changed: 241 additions & 82 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
2+
/logs
23
iroh.config.toml

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-base/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ digest = { version = "=0.11.0-rc.10", optional = true }
2222
# Pin sha2 to fix version incompatibility
2323
sha2 = { version = "=0.11.0-rc.2", optional = true }
2424
ed25519-dalek = { version = "=3.0.0-pre.1", features = ["serde", "rand_core", "zeroize"], optional = true }
25-
derive_more = { version = "2.0.1", features = ["display"], optional = true }
25+
derive_more = { version = "2.0.1", features = ["debug", "display"], optional = true }
2626
url = { version = "2.5.3", features = ["serde"], optional = true }
2727
rand_core = { version = "0.9.3", optional = true }
2828
serde = { version = "1", features = ["derive", "rc"] }

iroh-base/src/endpoint_addr.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ pub struct EndpointAddr {
4545
}
4646

4747
/// Available address types.
48-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
48+
#[derive(
49+
derive_more::Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash,
50+
)]
4951
#[non_exhaustive]
5052
pub enum TransportAddr {
5153
/// Relays
54+
#[debug("Relay({_0})")]
5255
Relay(RelayUrl),
5356
/// IP based addresses
5457
Ip(SocketAddr),

iroh/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ console_error_panic_hook = "0.1"
107107
postcard = { version = "1.1.1", features = ["use-std"] }
108108
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
109109
rand_chacha = "0.9"
110+
chrono = "0.4.43"
110111

111112
# *non*-wasm-in-browser test/dev dependencies
112113
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dev-dependencies]

0 commit comments

Comments
 (0)