-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(log): improve quality of debug level logs
- Loading branch information
1 parent
a594341
commit 7b59311
Showing
6 changed files
with
77 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,9 @@ where I: AsyncRead + AsyncWrite, | |
return Err(e); | ||
} | ||
}; | ||
|
||
debug!("incoming body is {}", decoder); | ||
|
||
self.state.busy(); | ||
if head.expecting_continue() { | ||
let msg = b"HTTP/1.1 100 Continue\r\n\r\n"; | ||
|
@@ -203,8 +206,11 @@ where I: AsyncRead + AsyncWrite, | |
if !slice.is_empty() { | ||
return Ok(Async::Ready(Some(super::Chunk::from(slice)))); | ||
} else if decoder.is_eof() { | ||
debug!("incoming body completed"); | ||
(Reading::KeepAlive, Ok(Async::Ready(None))) | ||
} else { | ||
trace!("decode stream unexpectedly ended"); | ||
//TODO: Should this return an UnexpectedEof? | ||
(Reading::Closed, Ok(Async::Ready(None))) | ||
} | ||
|
||
|
@@ -240,10 +246,12 @@ where I: AsyncRead + AsyncWrite, | |
assert!(!self.can_read_head() && !self.can_read_body()); | ||
|
||
if !self.io.read_buf().is_empty() { | ||
debug!("received an unexpected {} bytes", self.io.read_buf().len()); | ||
Err(io::Error::new(io::ErrorKind::InvalidData, "unexpected bytes after message ended")) | ||
} else { | ||
match self.io.read_from_io() { | ||
Ok(Async::Ready(0)) => { | ||
trace!("try_empty_read; found EOF on connection"); | ||
self.state.close_read(); | ||
let must_error = !self.state.is_idle() && T::should_error_on_parse_eof(); | ||
if must_error { | ||
|
@@ -252,11 +260,11 @@ where I: AsyncRead + AsyncWrite, | |
Ok(()) | ||
} | ||
}, | ||
Ok(Async::Ready(_)) => { | ||
Ok(Async::Ready(n)) => { | ||
debug!("received {} bytes on an idle connection", n); | ||
Err(io::Error::new(io::ErrorKind::InvalidData, "unexpected bytes after message ended")) | ||
}, | ||
Ok(Async::NotReady) => { | ||
trace!("try_empty_read; read blocked"); | ||
Ok(()) | ||
}, | ||
Err(e) => { | ||
|
@@ -616,7 +624,7 @@ where I: AsyncRead + AsyncWrite + 'static, | |
K: KeepAlive + 'static, | ||
T::Outgoing: fmt::Debug {} | ||
|
||
impl<I, B: AsRef<[u8]>, T, K: fmt::Debug> fmt::Debug for Conn<I, B, T, K> { | ||
impl<I, B: AsRef<[u8]>, T, K: KeepAlive> fmt::Debug for Conn<I, B, T, K> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_struct("Conn") | ||
.field("state", &self.state) | ||
|
@@ -650,13 +658,13 @@ enum Writing<B> { | |
Closed, | ||
} | ||
|
||
impl<B: AsRef<[u8]>, K: fmt::Debug> fmt::Debug for State<B, K> { | ||
impl<B: AsRef<[u8]>, K: KeepAlive> fmt::Debug for State<B, K> { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_struct("State") | ||
.field("reading", &self.reading) | ||
.field("writing", &self.writing) | ||
.field("keep_alive", &self.keep_alive) | ||
.field("method", &self.method) | ||
.field("keep_alive", &self.keep_alive.status()) | ||
//.field("method", &self.method) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mathstuf
Contributor
|
||
.field("read_task", &self.read_task) | ||
.finish() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is this comment a leftover from debugging? Should it still be commented out?