Skip to content

Commit

Permalink
feat(core): add logs for OrTransport when trying addresses
Browse files Browse the repository at this point in the history
Currently, when trying addresses in `listen_on` via `OrTransport`, there are no logs to facilitate debugging. This PR corrects that by providing adequate logs via `std::any::type_name` method.

Resolves #4072.

Pull-Request: #4133.
  • Loading branch information
tcoratger committed Jul 5, 2023
1 parent f0fd535 commit 7308221
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions core/src/transport/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::either::EitherFuture;
use crate::transport::{ListenerId, Transport, TransportError, TransportEvent};
use either::Either;
use futures::future;
use log::{debug, trace};
use multiaddr::Multiaddr;
use std::{pin::Pin, task::Context, task::Poll};

Expand Down Expand Up @@ -51,13 +52,37 @@ where
id: ListenerId,
addr: Multiaddr,
) -> Result<(), TransportError<Self::Error>> {
trace!(
"Attempting to dial {} using {}",
addr,
std::any::type_name::<A>()
);
let addr = match self.0.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => addr,
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
std::any::type_name::<A>()
);
addr
}
res => return res.map_err(|err| err.map(Either::Left)),
};

trace!(
"Attempting to dial {} using {}",
addr,
std::any::type_name::<B>()
);
let addr = match self.1.listen_on(id, addr) {
Err(TransportError::MultiaddrNotSupported(addr)) => addr,
Err(TransportError::MultiaddrNotSupported(addr)) => {
debug!(
"Failed to dial {} using {}",
addr,
std::any::type_name::<B>()
);
addr
}
res => return res.map_err(|err| err.map(Either::Right)),
};

Expand Down

0 comments on commit 7308221

Please sign in to comment.