Skip to content

Commit

Permalink
refactor(lib): improve client and h1 logs
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Feb 15, 2019
1 parent 877606d commit c0e08a4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,11 @@ impl ConnectingTcpRemote {
loop {
if let Some(ref mut current) = self.current {
match current.poll() {
Ok(ok) => return Ok(ok),
Ok(Async::Ready(tcp)) => {
debug!("connected to {:?}", tcp.peer_addr().ok());
return Ok(Async::Ready(tcp));
},
Ok(Async::NotReady) => return Ok(Async::NotReady),
Err(e) => {
trace!("connect error {:?}", e);
err = Some(e);
Expand Down
1 change: 1 addition & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ where C: Connect + Sync + 'static,
.http2_only(is_h2)
.handshake(io)
.and_then(move |(tx, conn)| {
trace!("handshake complete, spawning background dispatcher task");
let bg = executor.execute(conn.map_err(|e| {
debug!("client connection error: {}", e)
}));
Expand Down
1 change: 1 addition & 0 deletions src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ impl<T: Poolable> Future for Checkout<T> {
impl<T> Drop for Checkout<T> {
fn drop(&mut self) {
if self.waiter.take().is_some() {
trace!("checkout dropped for {:?}", self.key);
if let Some(Ok(mut inner)) = self.pool.inner.as_ref().map(|i| i.lock()) {
inner.clean_waiters(&self.key);
}
Expand Down
21 changes: 13 additions & 8 deletions src/proto/h1/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ where I: AsyncRead + AsyncWrite,
pub fn read_keep_alive(&mut self) -> Result<(), ::Error> {
debug_assert!(!self.can_read_head() && !self.can_read_body());

trace!("read_keep_alive; is_mid_message={}", self.is_mid_message());

if self.is_mid_message() {
self.mid_message_detect_eof().map_err(::Error::new_io)
} else {
Expand Down Expand Up @@ -279,6 +277,7 @@ where I: AsyncRead + AsyncWrite,
Err(io::Error::new(io::ErrorKind::InvalidData, desc))
},
Async::NotReady => {
trace!("read_keep_alive check: ok, nothing to read yet");
Ok(())
},
}
Expand Down Expand Up @@ -715,14 +714,20 @@ enum Writing {

impl fmt::Debug for State {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("State")
let mut builder = f.debug_struct("State");
builder
.field("reading", &self.reading)
.field("writing", &self.writing)
.field("keep_alive", &self.keep_alive)
.field("error", &self.error)
//.field("method", &self.method)
//.field("title_case_headers", &self.title_case_headers)
.finish()
.field("keep_alive", &self.keep_alive);

// Only show error field if it's interesting...
if let Some(ref error) = self.error {
builder.field("error", error);
}

// Purposefully leaving off other fields..

builder.finish()
}
}

Expand Down

0 comments on commit c0e08a4

Please sign in to comment.