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);
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);
.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()));
}
);
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)
}
}
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)
}
}
fn poll_ready(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
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);
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
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(()))