@@ -11,7 +11,6 @@ use std::io;
1111use std:: pin:: Pin ;
1212use std:: task:: { ready, Context , Poll } ;
1313use tokio:: sync:: mpsc;
14- use tracing:: { error, info} ;
1514
1615pin_project ! {
1716 #[ derive( Debug ) ]
@@ -139,7 +138,7 @@ impl Write for TxReadyStream {
139138 Poll :: Ready ( Ok ( len) )
140139 }
141140 Err ( _) => {
142- error ! ( "ReadyStream::poll_write failed - channel closed" ) ;
141+ println ! ( "ReadyStream::poll_write failed - channel closed" ) ;
143142 Poll :: Ready ( Err ( io:: Error :: new (
144143 io:: ErrorKind :: BrokenPipe ,
145144 "Write channel closed" ,
@@ -165,7 +164,7 @@ impl Write for TxReadyStream {
165164
166165 // Abort the panic task if it exists
167166 if let Some ( task) = self . panic_task . take ( ) {
168- info ! ( "Task polled to completion. Aborting panic (aka waker stand-in task)." ) ;
167+ println ! ( "Task polled to completion. Aborting panic (aka waker stand-in task)." ) ;
169168 task. abort ( ) ;
170169 }
171170
@@ -178,32 +177,18 @@ impl Write for TxReadyStream {
178177 }
179178}
180179
181- fn init_tracing ( ) {
182- use std:: sync:: Once ;
183- static INIT : Once = Once :: new ( ) ;
184- INIT . call_once ( || {
185- tracing_subscriber:: fmt ( )
186- . with_max_level ( tracing:: Level :: INFO )
187- . with_target ( true )
188- . with_thread_ids ( true )
189- . with_thread_names ( true )
190- . init ( ) ;
191- } ) ;
192- }
193-
194180const TOTAL_CHUNKS : usize = 16 ;
195181
196182#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
197183async fn body_test ( ) {
198- init_tracing ( ) ;
199184 // Create a pair of connected streams
200185 let ( server_stream, mut client_stream) = TxReadyStream :: new_pair ( ) ;
201186
202187 let mut http_builder = http1:: Builder :: new ( ) ;
203188 http_builder. max_buf_size ( CHUNK_SIZE ) ;
204189 const CHUNK_SIZE : usize = 64 * 1024 ;
205190 let service = service_fn ( |_| async move {
206- info ! (
191+ println ! (
207192 "Creating payload of {} chunks of {} KiB each ({} MiB total)..." ,
208193 TOTAL_CHUNKS ,
209194 CHUNK_SIZE / 1024 ,
@@ -216,7 +201,7 @@ async fn body_test() {
216201 . map ( |b| Ok :: < _ , Infallible > ( Frame :: data ( b) ) ) ,
217202 ) ;
218203 let body = StreamBody :: new ( stream) ;
219- info ! ( "Server: Sending data response..." ) ;
204+ println ! ( "Server: Sending data response..." ) ;
220205 Ok :: < _ , hyper:: Error > (
221206 Response :: builder ( )
222207 . status ( StatusCode :: OK )
@@ -230,20 +215,20 @@ async fn body_test() {
230215 let server_task = tokio:: spawn ( async move {
231216 let conn = http_builder. serve_connection ( server_stream, service) ;
232217 if let Err ( e) = conn. await {
233- error ! ( "Server connection error: {}" , e) ;
218+ println ! ( "Server connection error: {}" , e) ;
234219 }
235220 } ) ;
236221
237222 let get_request = "GET / HTTP/1.1\r \n Host: localhost\r \n Connection: close\r \n \r \n " ;
238223 client_stream. send ( get_request. as_bytes ( ) ) . unwrap ( ) ;
239224
240- info ! ( "Client is reading response..." ) ;
225+ println ! ( "Client is reading response..." ) ;
241226 let mut bytes_received = 0 ;
242227 while let Some ( chunk) = client_stream. recv ( ) . await {
243228 bytes_received += chunk. len ( ) ;
244229 }
245230 // Clean up
246231 server_task. abort ( ) ;
247232
248- info ! ( bytes_received , "Client done receiving bytes" ) ;
233+ println ! ( "Client done receiving bytes: {}" , bytes_received ) ;
249234}
0 commit comments