From 717a0021ac642e28b460acef9858f04bda82f005 Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Wed, 24 Apr 2024 13:39:22 -0300 Subject: [PATCH] src: Replace all dbg to tracing info and tracing-test macro --- src/decoder.rs | 8 +++++++- tests/deserialize.rs | 7 +++++-- tests/packer.rs | 2 ++ tests/serialize.rs | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/decoder.rs b/src/decoder.rs index 48ee52804..802b86e22 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -1,3 +1,5 @@ +use tracing::info; + use crate::message::{ProtocolMessage, HEADER}; #[derive(Debug, PartialEq)] @@ -77,7 +79,11 @@ impl Decoder { } DecoderState::ReadingPayload => { self.buffer.push(byte); - dbg!(self.buffer.len(), self.message.payload_length); + info!( + "DecoderState : ReadingPayload {:?} {:?}", + self.buffer.len(), + self.message.payload_length + ); if self.buffer.len() == self.message.payload_length as usize { self.message.payload = self.buffer.clone(); self.state = DecoderState::ReadingChecksum; diff --git a/tests/deserialize.rs b/tests/deserialize.rs index a21000640..434bd1c3d 100644 --- a/tests/deserialize.rs +++ b/tests/deserialize.rs @@ -3,7 +3,10 @@ use std::convert::TryFrom; use ping_rs::common::Messages as common_messages; use ping_rs::decoder::*; use ping_rs::{common, Messages}; +use tracing::info; +use tracing_test::traced_test; +#[traced_test] #[test] fn test_simple_deserialization() { let mut decoder = Decoder::new(); @@ -24,7 +27,7 @@ fn test_simple_deserialization() { assert_eq!(general_request, parsed); for byte in &buffer[0..buffer.len() - 2] { - dbg!(byte, &decoder.state); + info!("byte : {byte}, {:?}", &decoder.state); assert!(matches!( decoder.parse_byte(byte.clone()), DecoderResult::InProgress @@ -35,7 +38,7 @@ fn test_simple_deserialization() { DecoderResult::InProgress )); let DecoderResult::Success(_message) = decoder.parse_byte(buffer[buffer.len() - 1]) else { - dbg!(decoder.state); + info!("Decoder state: {:?}", decoder.state); panic!("Failed to use decoder with valid message"); }; diff --git a/tests/packer.rs b/tests/packer.rs index a83052793..875ff34d1 100644 --- a/tests/packer.rs +++ b/tests/packer.rs @@ -1,6 +1,8 @@ use ping_rs::common::{self, Messages as common_messages}; use ping_rs::message::{MessageInfo, PingMessage, ProtocolMessage}; +use tracing_test::traced_test; +#[traced_test] #[test] fn test_same_packer() { let mut packer = ProtocolMessage::new(); diff --git a/tests/serialize.rs b/tests/serialize.rs index 9f17c7f98..9bf8aabe9 100644 --- a/tests/serialize.rs +++ b/tests/serialize.rs @@ -1,6 +1,8 @@ use ping_rs::common; use ping_rs::message::SerializePayload; +use tracing_test::traced_test; +#[traced_test] #[test] fn test_simple_serialization() { let general_request = common::GeneralRequestStruct { requested_id: 5 };