Remove all targets from log statements. (#195)

The default uses crate + module path anyway, so `target` has been
redundant, causes more work when renaming crates and makes log
lines longer.
This commit is contained in:
Toralf Wittner
2018-05-17 15:14:13 +02:00
committed by GitHub
parent cb800624f5
commit 86a21fc43e
22 changed files with 158 additions and 217 deletions

View File

@ -72,8 +72,8 @@ where
info: IdentifyInfo,
observed_addr: &Multiaddr,
) -> Box<Future<Item = (), Error = IoError> + 'a> {
debug!(target: "libp2p-identify", "Sending identify info to client");
trace!(target: "libp2p-identify", "Sending: {:?}", info);
debug!("Sending identify info to client");
trace!("Sending: {:?}", info);
let listen_addrs = info.listen_addrs
.into_iter()
@ -128,11 +128,10 @@ where
}
fn upgrade(self, socket: C, _: (), ty: Endpoint, observed_addr: &Multiaddr) -> Self::Future {
trace!(target: "libp2p-identify", "Upgrading connection with {:?} as {:?}",
observed_addr, ty);
trace!("Upgrading connection with {:?} as {:?}", observed_addr, ty);
let socket = socket.framed(VarintCodec::default());
let observed_addr_log = if log_enabled!(target: "libp2p-identify", Level::Debug) {
let observed_addr_log = if log_enabled!(Level::Debug) {
Some(observed_addr.clone())
} else {
None
@ -145,8 +144,8 @@ where
.map(|(msg, _)| msg)
.map_err(|(err, _)| err)
.and_then(|msg| {
if log_enabled!(target: "libp2p-identify", Level::Debug) {
debug!(target: "libp2p-identify", "Received identify message from {:?}",
if log_enabled!(Level::Debug) {
debug!("Received identify message from {:?}",
observed_addr_log
.expect("Programmer error: expected `observed_addr_log' to be \
non-None since debug log level is enabled"));
@ -156,23 +155,20 @@ where
let (info, observed_addr) = match parse_proto_msg(msg) {
Ok(v) => v,
Err(err) => {
debug!(target: "libp2p-identify",
"Failed to parse protobuf message ; error = {:?}", err);
debug!("Failed to parse protobuf message ; error = {:?}", err);
return Err(err.into());
}
};
trace!(target: "libp2p-identify", "Remote observes us as {:?}",
observed_addr);
trace!(target: "libp2p-identify", "Information received: {:?}", info);
trace!("Remote observes us as {:?}", observed_addr);
trace!("Information received: {:?}", info);
Ok(IdentifyOutput::RemoteInfo {
info,
observed_addr,
})
} else {
debug!(target: "libp2p-identify", "Identify protocol stream closed \
before receiving info");
debug!("Identify protocol stream closed before receiving info");
Err(IoErrorKind::InvalidData.into())
}
});

View File

@ -101,17 +101,14 @@ where
};
if peer.addrs().any(|addr| addr == client_addr) {
debug!(target: "libp2p-identify", "Incoming substream from {} \
identified as {:?}", client_addr,
peer_id);
debug!("Incoming substream from {} identified as {:?}", client_addr, peer_id);
let out = IdentifyTransportOutput { socket: connec, observed_addr: None };
let ret = (out, AddrComponent::P2P(peer_id.into_bytes()).into());
return future::Either::A(future::ok(ret));
}
}
debug!(target: "libp2p-identify", "Incoming connection from {}, dialing back \
in order to identify", client_addr);
debug!("Incoming connection from {}, dialing back in order to identify", client_addr);
// Dial the address that connected to us and try upgrade with the
// identify protocol.
let future = identify_upgrade
@ -143,14 +140,12 @@ where
),
};
debug!(target: "libp2p-identify", "Identified {} as {}", original_addr,
real_addr);
debug!("Identified {} as {}", original_addr, real_addr);
let out = IdentifyTransportOutput { socket: connec, observed_addr: Some(observed) };
Ok((out, real_addr))
})
.map_err(move |err| {
warn!(target: "libp2p-identify", "Failed to identify incoming {}",
client_addr);
warn!("Failed to identify incoming {}", client_addr);
err
});
future::Either::B(future)
@ -176,8 +171,7 @@ where
.collect::<Vec<_>>()
.into_iter();
trace!(target: "libp2p-identify", "Try dialing peer ID {:?} ; {} multiaddrs \
loaded from peerstore", peer_id, addrs.len());
trace!("Try dialing peer ID {:?} ; {} multiaddrs loaded from peerstore", peer_id, addrs.len());
let transport = self.transport;
let future = stream::iter_ok(addrs)
@ -186,8 +180,7 @@ where
match transport.clone().dial(addr) {
Ok(dial) => Some(dial),
Err((_, addr)) => {
warn!(target: "libp2p-identify", "Address {} not supported by \
underlying transport", addr);
warn!("Address {} not supported by underlying transport", addr);
None
},
}
@ -201,15 +194,12 @@ where
.and_then(move |(val, _)| {
match val {
Some((connec, inner_addr)) => {
debug!(target: "libp2p-identify", "Successfully dialed peer {:?} \
through {}", peer_id,
inner_addr);
debug!("Successfully dialed peer {:?} through {}", peer_id, inner_addr);
let out = IdentifyTransportOutput { socket: connec, observed_addr: None };
Ok((out, inner_addr))
},
None => {
debug!(target: "libp2p-identify", "All multiaddresses failed when \
dialing peer {:?}", peer_id);
debug!("All multiaddresses failed when dialing peer {:?}", peer_id);
// TODO: wrong error
Err(IoErrorKind::InvalidData.into())
},
@ -227,7 +217,7 @@ where
let transport = self.transport;
let identify_upgrade = transport.clone().with_upgrade(IdentifyProtocolConfig);
trace!(target: "libp2p-identify", "Pass through when dialing {}", addr);
trace!("Pass through when dialing {}", addr);
// We dial a first time the node and upgrade it to identify.
let dial = match identify_upgrade.dial(addr) {
@ -311,9 +301,7 @@ where
};
if peer.addrs().any(|addr| addr == client_addr) {
debug!(target: "libp2p-identify", "Incoming substream from {} \
identified as {:?}", client_addr,
peer_id);
debug!("Incoming substream from {} identified as {:?}", client_addr, peer_id);
let out = IdentifyTransportOutput { socket: connec, observed_addr: None };
let ret = (out, AddrComponent::P2P(peer_id.into_bytes()).into());
return future::Either::A(future::ok(ret));