Use log::debug in debug mode to trace communication with server

main
Laurent Pelecq 2 years ago
parent c45bb7daa7
commit bf33d18bb2

@ -11,6 +11,7 @@ repository = "https://gitlab.com/lp-accessibility/ssip-client"
[dependencies]
dirs = "4"
log = { version = "0.4", features = ["max_level_debug", "release_max_level_info"] }
mio = { version = "0.8", optional = true }
thiserror = "1"
strum = "0.24"

@ -7,6 +7,7 @@
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
use log::debug;
use std::io::{self, BufRead, Write};
use crate::client::{ClientError, ClientResult, ClientStatus};
@ -24,7 +25,7 @@ macro_rules! invalid_input {
/// Write lines separated by CRLF.
pub(crate) fn write_lines(output: &mut dyn Write, lines: &[&str]) -> ClientResult<()> {
for line in lines.iter() {
// Uncomment to debug: dbg!(line.to_owned());
debug!("SSIP(out): {}", line);
output.write_all(line.as_bytes())?;
output.write_all(b"\r\n")?;
}
@ -64,7 +65,7 @@ pub(crate) fn receive_answer(
loop {
let mut line = String::new();
input.read_line(&mut line).map_err(ClientError::Io)?;
// Uncomment to debug: dbg!(line.to_owned());
debug!("SSIP(in): {}", line.trim_end());
match line.chars().nth(3) {
Some(ch) => match ch {
' ' => match line[0..3].parse::<u16>() {

Loading…
Cancel
Save