@@ -50,7 +50,20 @@ impl<S: SessionStream> AsyncRead for LoggingStream<S> {
50
50
cx : & mut Context < ' _ > ,
51
51
buf : & mut ReadBuf < ' _ > ,
52
52
) -> Poll < std:: io:: Result < ( ) > > {
53
- self . project ( ) . inner . poll_read ( cx, buf)
53
+ let projected = self . project ( ) ;
54
+ let old_remaining = buf. remaining ( ) ;
55
+
56
+ let res = projected. inner . poll_read ( cx, buf) ;
57
+
58
+ let n = old_remaining - buf. remaining ( ) ;
59
+ let log_message = format ! ( "{}: READING {}" , projected. tag, n) ;
60
+ projected. events . emit ( Event {
61
+ id : 0 ,
62
+ typ : EventType :: Info ( log_message) ,
63
+ } ) ;
64
+
65
+
66
+ res
54
67
}
55
68
}
56
69
@@ -60,7 +73,7 @@ impl<S: SessionStream> AsyncWrite for LoggingStream<S> {
60
73
cx : & mut std:: task:: Context < ' _ > ,
61
74
buf : & [ u8 ] ,
62
75
) -> Poll < std:: io:: Result < usize > > {
63
- let log_message = format ! ( "WRITING {}" , buf. len( ) ) ;
76
+ let log_message = format ! ( "{}: WRITING {}" , self . tag , buf. len( ) ) ;
64
77
65
78
let projected = self . project ( ) ;
66
79
projected. events . emit ( Event {
@@ -75,7 +88,15 @@ impl<S: SessionStream> AsyncWrite for LoggingStream<S> {
75
88
self : Pin < & mut Self > ,
76
89
cx : & mut std:: task:: Context < ' _ > ,
77
90
) -> Poll < std:: io:: Result < ( ) > > {
78
- self . project ( ) . inner . poll_flush ( cx)
91
+ let log_message = format ! ( "{}: FLUSH" , self . tag) ;
92
+
93
+ let projected = self . project ( ) ;
94
+ projected. events . emit ( Event {
95
+ id : 0 ,
96
+ typ : EventType :: Info ( log_message) ,
97
+ } ) ;
98
+
99
+ projected. inner . poll_flush ( cx)
79
100
}
80
101
81
102
fn poll_shutdown (
0 commit comments