From 5101fa7ce58209af2e12a73d9fae444a2997ec2e Mon Sep 17 00:00:00 2001 From: Sachandhan Ganesh Date: Fri, 15 Jan 2021 13:31:13 -0800 Subject: [PATCH] lower the log level of debug stmts to trace --- src/reader.rs | 15 +++++++-------- src/tcp/server.rs | 2 +- src/tls/server.rs | 4 ++-- src/writer.rs | 22 +++++++++++----------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 1dd9f98..8dcb089 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -51,17 +51,17 @@ impl Stream for ConnectionReader { let mut buffer = BytesMut::new(); buffer.resize(BUFFER_SIZE, 0); - debug!("Starting new read loop for {}", self.local_addr); + trace!("Starting new read loop for {}", self.local_addr); loop { trace!("Reading from the stream"); match futures::executor::block_on(self.read_stream.read(&mut buffer)) { Ok(mut bytes_read) => { if bytes_read > 0 { - debug!("Read {} bytes from the network stream", bytes_read) + trace!("Read {} bytes from the network stream", bytes_read) } if let Some(mut pending_buf) = self.pending_read.take() { - debug!("Prepending broken data ({} bytes) encountered from earlier read of network stream", pending_buf.len()); + trace!("Prepending broken data ({} bytes) encountered from earlier read of network stream", pending_buf.len()); bytes_read += pending_buf.len(); pending_buf.unsplit(buffer); @@ -72,18 +72,17 @@ impl Stream for ConnectionReader { format!("Conversion from usize ({}) to u64 failed", bytes_read).as_str(), ); while bytes_read_u64 > 0 { - debug!( + trace!( "{} bytes from network stream still unprocessed", bytes_read_u64 ); buffer.resize(bytes_read, 0); - debug!("{:?}", buffer.as_ref()); match ConnectionMessage::parse_from_bytes(buffer.as_ref()) { Ok(mut data) => { let serialized_size = data.compute_size(); - debug!("Deserialized message of size {} bytes", serialized_size); + trace!("Deserialized message of size {} bytes", serialized_size); buffer.advance(serialized_size as usize); @@ -95,9 +94,9 @@ impl Stream for ConnectionReader { .as_str(), ); bytes_read_u64 -= serialized_size_u64; - debug!("{} bytes still unprocessed", bytes_read_u64); + trace!("{} bytes still unprocessed", bytes_read_u64); - debug!("Sending deserialized message downstream"); + trace!("Sending deserialized message downstream"); return Poll::Ready(Some(data.take_payload())); } diff --git a/src/tcp/server.rs b/src/tcp/server.rs index 136c3f1..09c51d1 100644 --- a/src/tcp/server.rs +++ b/src/tcp/server.rs @@ -36,7 +36,7 @@ impl Stream for TcpServer { ); Poll::Ready(Some(Connection::from(conn))) } else { - debug!("Shutting TCP server down at {}", self.local_addrs); + info!("Shutting TCP server down at {}", self.local_addrs); Poll::Ready(None) } } diff --git a/src/tls/server.rs b/src/tls/server.rs index cfd06f8..4d92e2e 100644 --- a/src/tls/server.rs +++ b/src/tls/server.rs @@ -53,11 +53,11 @@ impl Stream for TlsServer { stream: tls_stream, }))) } else { - debug!("Could not encrypt connection with TLS from {}", peer_addr); + warn!("Could not encrypt connection with TLS from {}", peer_addr); Poll::Pending } } else { - debug!("Shutting TLS server down at {}", self.local_addrs); + info!("Shutting TLS server down at {}", self.local_addrs); Poll::Ready(None) } } diff --git a/src/writer.rs b/src/writer.rs index c2275ac..5b5b17a 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -45,16 +45,16 @@ impl Sink for ConnectionWriter { fn poll_ready(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { if self.pending_write.is_some() { - debug!("Connection not ready to send message yet, waiting for prior message"); + trace!("Connection not ready to send message yet, waiting for prior message"); Poll::Pending } else { - debug!("Connection ready to send message"); + trace!("Connection ready to send message"); Poll::Ready(Ok(())) } } fn start_send(mut self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> { - debug!("Preparing message to be sent next"); + trace!("Preparing message to be sent next"); let stitch_msg: ConnectionMessage = ConnectionMessage::from_msg(item); self.pending_write.replace(stitch_msg); @@ -66,33 +66,33 @@ impl Sink for ConnectionWriter { _cx: &mut Context<'_>, ) -> Poll> { if let Some(pending_msg) = self.pending_write.take() { - debug!("Send pending message"); + trace!("Send pending message"); if let Ok(buffer) = pending_msg.write_to_bytes() { let msg_size = buffer.len(); - debug!("{} bytes to be sent over network connection", msg_size); + trace!("{} bytes to be sent over network connection", msg_size); - debug!("{:?}", buffer.as_slice()); + trace!("{:?}", buffer.as_slice()); return if let Ok(_) = futures::executor::block_on(self.write_stream.write_all(buffer.as_slice())) { if let Ok(_) = futures::executor::block_on(self.write_stream.flush()) { - debug!("Sent message of {} bytes", msg_size); + trace!("Sent message of {} bytes", msg_size); Poll::Ready(Ok(())) } else { - debug!("Encountered error while flushing queued bytes to network stream"); + trace!("Encountered error while flushing queued bytes to network stream"); Poll::Ready(Err(RecvError)) } } else { - debug!("Encountered error when writing to network stream"); + error!("Encountered error when writing to network stream"); Poll::Ready(Err(RecvError)) }; } else { - debug!("Encountered error when serializing message to bytes"); + error!("Encountered error when serializing message to bytes"); return Poll::Ready(Err(RecvError)); } } else { - debug!("No message to send over connection"); + trace!("No message to send over connection"); } Poll::Ready(Ok(())) -- 2.44.0