Skip to content

Commit 423a986

Browse files
authored
fix(iroh): remove superflious info log (#3080)
## Description Not every relay connection created needs to be logged on info level. ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## 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.
1 parent 3fedee9 commit 423a986

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

iroh/src/magicsock/relay_actor.rs

+25-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use tokio::{
5656
time::{Duration, Instant, MissedTickBehavior},
5757
};
5858
use tokio_util::sync::CancellationToken;
59-
use tracing::{debug, error, info, info_span, instrument, trace, warn, Instrument};
59+
use tracing::{debug, error, event, info_span, instrument, trace, warn, Instrument, Level};
6060
use url::Url;
6161

6262
use super::RelayDatagramSendChannelReceiver;
@@ -288,6 +288,18 @@ impl ActiveRelayActor {
288288
.reset(Instant::now() + RELAY_INACTIVE_CLEANUP_TIME);
289289
}
290290

291+
fn set_home_relay(&mut self, is_home: bool) {
292+
let prev = std::mem::replace(&mut self.is_home_relay, is_home);
293+
if self.is_home_relay != prev {
294+
event!(
295+
target: "iroh::_events::relay::home_changed",
296+
Level::DEBUG,
297+
url = %self.url,
298+
home_relay = self.is_home_relay,
299+
);
300+
}
301+
}
302+
291303
/// Actor loop when connecting to the relay server.
292304
///
293305
/// Returns `None` if the actor needs to shut down. Returns `Some(client)` when the
@@ -341,8 +353,8 @@ impl ActiveRelayActor {
341353
break None;
342354
};
343355
match msg {
344-
ActiveRelayMessage::SetHomeRelay(is_preferred) => {
345-
self.is_home_relay = is_preferred;
356+
ActiveRelayMessage::SetHomeRelay(is_home) => {
357+
self.set_home_relay(is_home);
346358
}
347359
ActiveRelayMessage::CheckConnection(_local_ips) => {}
348360
#[cfg(test)]
@@ -412,6 +424,12 @@ impl ActiveRelayActor {
412424
/// to the relay server is lost.
413425
async fn run_connected(&mut self, client: iroh_relay::client::Client) -> Result<()> {
414426
debug!("Actor loop: connected to relay");
427+
event!(
428+
target: "iroh::_events::relay::connected",
429+
Level::DEBUG,
430+
url = %self.url,
431+
home_relay = self.is_home_relay,
432+
);
415433

416434
let (mut client_stream, mut client_sink) = client.split();
417435

@@ -458,8 +476,8 @@ impl ActiveRelayActor {
458476
break Ok(());
459477
};
460478
match msg {
461-
ActiveRelayMessage::SetHomeRelay(is_preferred) => {
462-
self.is_home_relay = is_preferred;
479+
ActiveRelayMessage::SetHomeRelay(is_home) => {
480+
self.set_home_relay(is_home);
463481
}
464482
ActiveRelayMessage::CheckConnection(local_ips) => {
465483
match client_stream.local_addr() {
@@ -906,7 +924,7 @@ impl RelayActor {
906924
}
907925

908926
fn start_active_relay(&mut self, url: RelayUrl) -> ActiveRelayHandle {
909-
info!(?url, "Adding relay connection");
927+
debug!(?url, "Adding relay connection");
910928

911929
let connection_opts = RelayConnectionOptions {
912930
secret_key: self.msock.secret_key.clone(),
@@ -1211,6 +1229,7 @@ mod tests {
12111229
use smallvec::smallvec;
12121230
use testresult::TestResult;
12131231
use tokio_util::task::AbortOnDropHandle;
1232+
use tracing::info;
12141233

12151234
use super::*;
12161235
use crate::test_utils;

0 commit comments

Comments
 (0)