@@ -138,6 +138,10 @@ impl Connection {
138138 & self . 0 . io
139139 }
140140
141+ pub ( crate ) fn tag ( & self ) -> & ' static str {
142+ self . 0 . io . tag ( )
143+ }
144+
141145 pub ( crate ) fn codec ( & self ) -> & Codec {
142146 & self . 0 . codec
143147 }
@@ -263,10 +267,13 @@ impl Connection {
263267
264268 pub ( crate ) fn disconnect_when_ready ( & self ) {
265269 if self . 0 . streams . borrow ( ) . is_empty ( ) {
266- log:: debug !( "All streams are closed, disconnecting" ) ;
270+ log:: trace !( "{}: All streams are closed, disconnecting" , self . tag ( ) ) ;
267271 self . 0 . io . close ( ) ;
268272 } else {
269- log:: debug!( "Not all streams are closed, set disconnect flag" ) ;
273+ log:: trace!(
274+ "{}: Not all streams are closed, set disconnect flag" ,
275+ self . tag( )
276+ ) ;
270277 self . set_flags ( ConnectionFlags :: DISCONNECT_WHEN_READY ) ;
271278 }
272279 }
@@ -282,7 +289,10 @@ impl Connection {
282289 self . check_error ( ) ?;
283290
284291 if !self . can_create_new_stream ( ) {
285- log:: warn!( "Cannot create new stream, waiting for available streams" ) ;
292+ log:: warn!(
293+ "{}: Cannot create new stream, waiting for available streams" ,
294+ self . tag( )
295+ ) ;
286296 self . ready ( ) . await ?
287297 }
288298
@@ -326,7 +336,12 @@ impl Connection {
326336 let empty = {
327337 let mut streams = self . 0 . streams . borrow_mut ( ) ;
328338 if let Some ( stream) = streams. remove ( & id) {
329- log:: trace!( "Dropping stream {:?} remote: {:?}" , id, stream. is_remote( ) ) ;
339+ log:: trace!(
340+ "{}: Dropping stream {:?} remote: {:?}" ,
341+ self . tag( ) ,
342+ id,
343+ stream. is_remote( )
344+ ) ;
330345 if stream. is_remote ( ) {
331346 self . 0
332347 . active_remote_streams
@@ -352,7 +367,7 @@ impl Connection {
352367
353368 // Close connection
354369 if empty && flags. contains ( ConnectionFlags :: DISCONNECT_WHEN_READY ) {
355- log:: debug !( "All streams are closed, disconnecting" ) ;
370+ log:: trace !( "{}: All streams are closed, disconnecting" , self . tag ( ) ) ;
356371 self . 0 . io . close ( ) ;
357372 return ;
358373 }
@@ -379,6 +394,10 @@ impl Connection {
379394}
380395
381396impl RecvHalfConnection {
397+ pub ( crate ) fn tag ( & self ) -> & ' static str {
398+ self . 0 . io . tag ( )
399+ }
400+
382401 fn query ( & self , id : StreamId ) -> Option < StreamRef > {
383402 self . 0 . streams . borrow_mut ( ) . get ( & id) . cloned ( )
384403 }
@@ -614,7 +633,7 @@ impl RecvHalfConnection {
614633 & self ,
615634 frm : frame:: WindowUpdate ,
616635 ) -> Result < ( ) , Either < ConnectionError , StreamErrorInner > > {
617- log:: trace!( "processing incoming {:#?}" , frm) ;
636+ log:: trace!( "{}: processing incoming {:#?}" , self . tag ( ) , frm) ;
618637
619638 if frm. stream_id ( ) . is_zero ( ) {
620639 if frm. size_increment ( ) == 0 {
@@ -658,7 +677,7 @@ impl RecvHalfConnection {
658677 & self ,
659678 frm : frame:: Reset ,
660679 ) -> Result < ( ) , Either < ConnectionError , StreamErrorInner > > {
661- log:: trace!( "processing incoming {:#?}" , frm) ;
680+ log:: trace!( "{}: processing incoming {:#?}" , self . tag ( ) , frm) ;
662681
663682 if frm. stream_id ( ) . is_zero ( ) {
664683 Err ( Either :: Left ( ConnectionError :: UnknownStream ( "RST_STREAM" ) ) )
@@ -688,7 +707,8 @@ impl RecvHalfConnection {
688707 data : & Bytes ,
689708 ) -> HashMap < StreamId , StreamRef > {
690709 log:: trace!(
691- "processing go away with reason: {:?}, data: {:?}" ,
710+ "{}: processing go away with reason: {:?}, data: {:?}" ,
711+ self . tag( ) ,
692712 reason,
693713 data. slice( ..std:: cmp:: min( data. len( ) , 20 ) )
694714 ) ;
@@ -801,7 +821,7 @@ async fn delay_drop_task(state: Connection) {
801821 loop {
802822 if let Some ( item) = queue. front ( ) {
803823 if item. 1 <= now {
804- log:: trace!( "dropping {:?} after delay" , item. 0 ) ;
824+ log:: trace!( "{}: dropping {:?} after delay" , state . tag ( ) , item. 0 ) ;
805825 ids. remove ( & item. 0 ) ;
806826 queue. pop_front ( ) ;
807827 } else {
@@ -825,7 +845,10 @@ async fn ping(st: Connection, timeout: time::Seconds, io: IoRef) {
825845 st. set_flags ( ConnectionFlags :: RECV_PONG ) ;
826846 loop {
827847 if st. is_closed ( ) {
828- log:: debug!( "http client connection is closed, stopping keep-alive task" ) ;
848+ log:: trace!(
849+ "{}: http client connection is closed, stopping keep-alive task" ,
850+ st. tag( )
851+ ) ;
829852 break ;
830853 }
831854 sleep ( keepalive) . await ;
0 commit comments