send data log message

This commit is contained in:
Milo Turner 2020-03-08 01:29:15 -05:00
parent ff97bcc18c
commit 15b865a803
1 changed files with 11 additions and 1 deletions

View File

@ -36,7 +36,8 @@ impl Logger {
// -----------------------------------------------------------------------------------
pub async fn debug_msg<S: AsRef<str>>(&mut self, what: S) {
self.log_payload(LogPayload::Debug { what: what.as_ref() }).await
let what = what.as_ref();
self.log_payload(LogPayload::Debug { what }).await
}
pub async fn bound(&mut self, port: u16) {
@ -51,6 +52,10 @@ impl Logger {
pub async fn recv_data_ignored(&mut self) {
self.log_payload(LogPayload::RecvDataIgnored).await
}
pub async fn send_data(&mut self, start: usize, len: usize) {
self.log_payload(LogPayload::SendData { start, len }).await
}
}
struct LogMessage<'a> {
@ -71,6 +76,10 @@ enum LogPayload<'a> {
order: AcceptedOrder,
},
RecvDataIgnored,
SendData {
start: usize,
len: usize,
},
}
#[derive(Copy, Clone, Eq, PartialEq)]
@ -97,6 +106,7 @@ impl Display for LogPayload<'_> {
write!(f, "[recv data] {} ({}) ACCEPTED ({})", start, len, order)
}
LogPayload::RecvDataIgnored => write!(f, "[recv data] IGNORED"),
LogPayload::SendData { start, len } => write!(f, "[send data] {} ({})", start, len),
}
}
}