tokio-xmpp: Add some ugly premature logging useful for debugging

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2019-12-09 03:34:28 +01:00
parent 7c15653fac
commit db9f7a76be
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2
2 changed files with 17 additions and 19 deletions

View file

@ -15,6 +15,7 @@ edition = "2018"
bytes = "0.4" bytes = "0.4"
futures = "0.1" futures = "0.1"
idna = "0.2" idna = "0.2"
log = "0.4"
native-tls = "0.2" native-tls = "0.2"
sasl = "0.4" sasl = "0.4"
tokio = "0.1" tokio = "0.1"

View file

@ -2,6 +2,7 @@
use crate::{ParseError, ParserError}; use crate::{ParseError, ParserError};
use bytes::{BufMut, BytesMut}; use bytes::{BufMut, BytesMut};
use log::debug;
use std; use std;
use std::borrow::Cow; use std::borrow::Cow;
use std::cell::RefCell; use std::cell::RefCell;
@ -229,9 +230,9 @@ impl Decoder for XMPPCodec {
let buf1 = buf1.as_ref().as_ref(); let buf1 = buf1.as_ref().as_ref();
match from_utf8(buf1) { match from_utf8(buf1) {
Ok(mut s) => { Ok(mut s) => {
debug!("<< {:?}", s);
s = s.trim(); s = s.trim();
if !s.is_empty() { if !s.is_empty() {
// println!("<< {}", s);
let mut buffer_queue = BufferQueue::new(); let mut buffer_queue = BufferQueue::new();
let tendril = FromIterator::from_iter(s.chars()); let tendril = FromIterator::from_iter(s.chars());
buffer_queue.push_back(tendril); buffer_queue.push_back(tendril);
@ -296,26 +297,22 @@ impl Encoder for XMPPCodec {
} }
write!(buf, ">\n").map_err(to_io_err)?; write!(buf, ">\n").map_err(to_io_err)?;
// print!(">> {}", buf); debug!(">> {:?}", buf);
write!(dst, "{}", buf).map_err(to_io_err) write!(dst, "{}", buf).map_err(to_io_err)
} }
Packet::Stanza(stanza) => { Packet::Stanza(stanza) => stanza
stanza .write_to(&mut WriteBytes::new(dst))
.write_to(&mut WriteBytes::new(dst)) .and_then(|_| {
.and_then(|_| { debug!(">> {:?}", dst);
// println!(">> {:?}", dst); Ok(())
Ok(()) })
}) .map_err(|e| to_io_err(format!("{}", e))),
.map_err(|e| to_io_err(format!("{}", e))) Packet::Text(text) => write_text(&text, dst)
} .and_then(|_| {
Packet::Text(text) => { debug!(">> {:?}", dst);
write_text(&text, dst) Ok(())
.and_then(|_| { })
// println!(">> {:?}", dst); .map_err(to_io_err),
Ok(())
})
.map_err(to_io_err)
}
Packet::StreamEnd => write!(dst, "</stream:stream>\n").map_err(to_io_err), Packet::StreamEnd => write!(dst, "</stream:stream>\n").map_err(to_io_err),
} }
} }