mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-20 13:26:34 +00:00
feat(core): add logs for OrTransport
when trying addresses
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.
This commit is contained in:
@ -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};
|
||||
|
||||
@ -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)),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user