Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Change all error/warn logs to debug #47

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cid_prefix.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cid::{CidGeneric, Version};
use tracing::error;
use tracing::debug;

use crate::multihasher::{MultihasherError, MultihasherTable};

Expand Down Expand Up @@ -89,7 +89,7 @@ impl CidPrefix {
data: &[u8],
) -> Result<CidGeneric<S>, MultihasherError> {
if self.multihash_size > S {
error!(
debug!(
"Multihash<{}> can not hold multihash of size {}",
S, self.multihash_size
);
Expand Down
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use libp2p_swarm::{
ConnectionHandlerEvent, ConnectionId, NotifyHandler, StreamProtocol, SubstreamProtocol, ToSwarm,
};
use smallvec::SmallVec;
use tracing::warn;
use tracing::debug;

use crate::incoming_stream::ClientMessage;
use crate::message::Codec;
Expand Down Expand Up @@ -570,7 +570,7 @@ impl<const S: usize> ClientConnectionHandler<S> {
}

fn close_sink_on_error(&mut self, location: &str) {
warn!("sink operation failed, closing: {location}");
debug!("sink operation failed, closing: {location}");
self.sink_state = SinkState::None;
}

Expand Down
17 changes: 10 additions & 7 deletions src/incoming_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cid::CidGeneric;
use fnv::FnvHashMap;
use futures_util::future::{BoxFuture, Fuse, FusedFuture, FutureExt};
use futures_util::stream::StreamExt;
use tracing::error;
use tracing::debug;

use crate::cid_prefix::CidPrefix;
use crate::message::Codec;
Expand Down Expand Up @@ -87,7 +87,7 @@ impl<const S: usize> futures_core::stream::Stream for IncomingStream<S> {
let msg = match self.stream.poll_next_unpin(cx) {
Poll::Ready(Some(Ok(msg))) => msg,
Poll::Ready(Some(Err(e))) => {
error!("Message decoding failed: {e}");
debug!("Message decoding failed: {e}");
return Poll::Ready(None);
}
Poll::Ready(None) => return Poll::Ready(None),
Expand Down Expand Up @@ -116,7 +116,7 @@ async fn process_message<const S: usize>(
let cid = match CidGeneric::try_from(&block_presence.cid[..]) {
Ok(cid) => cid,
Err(e) => {
error!("Invalid CID bytes: {}: {:?}", e, block_presence.cid);
debug!("Invalid CID bytes: {}: {:?}", e, block_presence.cid);
return None;
}
};
Expand All @@ -130,23 +130,26 @@ async fn process_message<const S: usize>(

for payload in msg.payload {
let Some(cid_prefix) = CidPrefix::from_bytes(&payload.prefix) else {
error!("block.prefix not decodable: {:?}", payload.prefix);
debug!("block.prefix not decodable: {:?}", payload.prefix);
return None;
};

let cid = match cid_prefix.to_cid(&multihasher, &payload.data).await {
Ok(cid) => cid,
Err(MultihasherError::UnknownMultihashCode) => {
error!("Unknown multihash code: {}", cid_prefix.multihash_code());
debug!(
"Multihasher non-fatal error: Unknown multihash code: {}",
cid_prefix.multihash_code()
);
continue;
}
Err(MultihasherError::Custom(e)) => {
error!("{e}");
debug!("Multihasher non-fatal error: {e}");
continue;
}
// Any other error is fatal and we need to close the stream.
Err(e) => {
error!("{e}");
debug!("Multihasher fatal error: {e}");
return None;
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use libp2p_swarm::{
ConnectionHandlerEvent, NotifyHandler, StreamProtocol, SubstreamProtocol, ToSwarm,
};
use smallvec::SmallVec;
use tracing::{debug, trace, warn};
use tracing::{debug, trace};

use crate::incoming_stream::ServerMessage;
use crate::message::Codec;
Expand Down Expand Up @@ -271,7 +271,7 @@ where
self.outgoing_queue.push_back((cid, data));
}
Err(e) => {
warn!("Fetching {cid} from blockstore failed: {e}");
debug!("Fetching {cid} from blockstore failed: {e}");
}
}
}
Expand Down Expand Up @@ -393,7 +393,7 @@ impl<const S: usize> ServerConnectionHandler<S> {
}

fn close_sink_on_error(&mut self, location: &str) {
warn!("sink operation failed, closing: {location}");
debug!("sink operation failed, closing: {location}");
self.sink = SinkState::None;
}

Expand Down
Loading