Less verbose console output (#4029)

This commit is contained in:
Arkadiy Paronyan
2019-11-06 10:06:11 +01:00
committed by Bastian Köcher
parent f093eeba24
commit 1aaf31a34d
2 changed files with 9 additions and 8 deletions
+6 -5
View File
@@ -63,6 +63,7 @@ use libp2p::multiaddr::Protocol;
use log::{debug, info, trace, warn}; use log::{debug, info, trace, warn};
use std::{cmp, collections::VecDeque, time::Duration}; use std::{cmp, collections::VecDeque, time::Duration};
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use primitives::hexdisplay::HexDisplay;
/// Implementation of `NetworkBehaviour` that discovers the nodes on the network. /// Implementation of `NetworkBehaviour` that discovers the nodes on the network.
pub struct DiscoveryBehaviour<TSubstream> { pub struct DiscoveryBehaviour<TSubstream> {
@@ -316,16 +317,16 @@ where
KademliaEvent::GetClosestPeersResult(res) => { KademliaEvent::GetClosestPeersResult(res) => {
match res { match res {
Err(GetClosestPeersError::Timeout { key, peers }) => { Err(GetClosestPeersError::Timeout { key, peers }) => {
warn!(target: "sub-libp2p", debug!(target: "sub-libp2p",
"Libp2p => Query for {:?} timed out with {:?} results", "Libp2p => Query for {:?} timed out with {} results",
key, peers.len()); HexDisplay::from(&key), peers.len());
}, },
Ok(ok) => { Ok(ok) => {
trace!(target: "sub-libp2p", trace!(target: "sub-libp2p",
"Libp2p => Query for {:?} yielded {:?} results", "Libp2p => Query for {:?} yielded {:?} results",
ok.key, ok.peers.len()); HexDisplay::from(&ok.key), ok.peers.len());
if ok.peers.is_empty() && self.num_connections != 0 { if ok.peers.is_empty() && self.num_connections != 0 {
warn!(target: "sub-libp2p", "Libp2p => Random Kademlia query has yielded empty \ debug!(target: "sub-libp2p", "Libp2p => Random Kademlia query has yielded empty \
results"); results");
} }
} }
+3 -3
View File
@@ -180,17 +180,17 @@ impl OtherApi for () {
} }
fn print_num(val: u64) { fn print_num(val: u64) {
println!("{}", val); log::debug!(target: "runtime", "{}", val);
} }
fn print_utf8(utf8: &[u8]) { fn print_utf8(utf8: &[u8]) {
if let Ok(data) = std::str::from_utf8(utf8) { if let Ok(data) = std::str::from_utf8(utf8) {
println!("{}", data) log::debug!(target: "runtime", "{}", data)
} }
} }
fn print_hex(data: &[u8]) { fn print_hex(data: &[u8]) {
println!("{}", HexDisplay::from(&data)); log::debug!(target: "runtime", "{}", HexDisplay::from(&data));
} }
fn log( fn log(