tokio-xmpp: Add some ugly premature logging useful for debugging
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
7c15653fac
commit
db9f7a76be
2 changed files with 17 additions and 19 deletions
|
@ -15,6 +15,7 @@ edition = "2018"
|
|||
bytes = "0.4"
|
||||
futures = "0.1"
|
||||
idna = "0.2"
|
||||
log = "0.4"
|
||||
native-tls = "0.2"
|
||||
sasl = "0.4"
|
||||
tokio = "0.1"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use crate::{ParseError, ParserError};
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use log::debug;
|
||||
use std;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
|
@ -229,9 +230,9 @@ impl Decoder for XMPPCodec {
|
|||
let buf1 = buf1.as_ref().as_ref();
|
||||
match from_utf8(buf1) {
|
||||
Ok(mut s) => {
|
||||
debug!("<< {:?}", s);
|
||||
s = s.trim();
|
||||
if !s.is_empty() {
|
||||
// println!("<< {}", s);
|
||||
let mut buffer_queue = BufferQueue::new();
|
||||
let tendril = FromIterator::from_iter(s.chars());
|
||||
buffer_queue.push_back(tendril);
|
||||
|
@ -296,26 +297,22 @@ impl Encoder for XMPPCodec {
|
|||
}
|
||||
write!(buf, ">\n").map_err(to_io_err)?;
|
||||
|
||||
// print!(">> {}", buf);
|
||||
debug!(">> {:?}", buf);
|
||||
write!(dst, "{}", buf).map_err(to_io_err)
|
||||
}
|
||||
Packet::Stanza(stanza) => {
|
||||
stanza
|
||||
Packet::Stanza(stanza) => stanza
|
||||
.write_to(&mut WriteBytes::new(dst))
|
||||
.and_then(|_| {
|
||||
// println!(">> {:?}", dst);
|
||||
debug!(">> {:?}", dst);
|
||||
Ok(())
|
||||
})
|
||||
.map_err(|e| to_io_err(format!("{}", e)))
|
||||
}
|
||||
Packet::Text(text) => {
|
||||
write_text(&text, dst)
|
||||
.map_err(|e| to_io_err(format!("{}", e))),
|
||||
Packet::Text(text) => write_text(&text, dst)
|
||||
.and_then(|_| {
|
||||
// println!(">> {:?}", dst);
|
||||
debug!(">> {:?}", dst);
|
||||
Ok(())
|
||||
})
|
||||
.map_err(to_io_err)
|
||||
}
|
||||
.map_err(to_io_err),
|
||||
Packet::StreamEnd => write!(dst, "</stream:stream>\n").map_err(to_io_err),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue