@@ -5,6 +5,10 @@ use std::{
55 process:: Command ,
66 time:: { Duration , SystemTime , UNIX_EPOCH } ,
77} ;
8+ use tokio:: {
9+ io:: { AsyncBufReadExt , BufReader } ,
10+ process:: Command as TokioCommand ,
11+ } ;
812
913/// A wrapper that combines a provider with its human-readable name for testing
1014pub struct NamedProvider {
@@ -53,6 +57,9 @@ impl DockerComposeEnv {
5357 // Start the environment
5458 let env = Self :: start_environment ( & compose_file, & project_name) ?;
5559
60+ // Start streaming logs in the background
61+ let _ = Self :: stream_container_logs ( & compose_file, & project_name) . await ;
62+
5663 // Wait for all services to be ready
5764 tracing:: info!( "⏳ Waiting for services to be ready..." ) ;
5865 Self :: wait_for_l2_node_ready ( RN_SEQUENCER_RPC_URL , 30 ) . await ?;
@@ -208,6 +215,45 @@ impl DockerComposeEnv {
208215 ) ;
209216 }
210217
218+ /// Stream logs from all containers in the background to the `docker-compose` target aat trace
219+ /// level.
220+ async fn stream_container_logs ( compose_file : & str , project_name : & str ) -> eyre:: Result < ( ) > {
221+ let mut child = TokioCommand :: new ( "docker" )
222+ . args ( [
223+ "compose" ,
224+ "-f" ,
225+ compose_file,
226+ "-p" ,
227+ project_name,
228+ "logs" ,
229+ "-f" , // follow mode
230+ "--no-color" , // avoid ANSI mess
231+ ] )
232+ . stdout ( std:: process:: Stdio :: piped ( ) )
233+ . stderr ( std:: process:: Stdio :: piped ( ) )
234+ . spawn ( ) ?;
235+
236+ if let Some ( stdout) = child. stdout . take ( ) {
237+ let mut reader = BufReader :: new ( stdout) . lines ( ) ;
238+ tokio:: spawn ( async move {
239+ while let Ok ( Some ( line) ) = reader. next_line ( ) . await {
240+ tracing:: trace!( target: "docker-compose" , "{}" , line) ;
241+ }
242+ } ) ;
243+ }
244+
245+ if let Some ( stderr) = child. stderr . take ( ) {
246+ let mut reader = BufReader :: new ( stderr) . lines ( ) ;
247+ tokio:: spawn ( async move {
248+ while let Ok ( Some ( line) ) = reader. next_line ( ) . await {
249+ tracing:: trace!( target: "docker-compose" , "{}" , line) ;
250+ }
251+ } ) ;
252+ }
253+
254+ Ok ( ( ) )
255+ }
256+
211257 /// Show logs for all containers
212258 fn show_all_container_logs ( compose_file : & str , project_name : & str ) {
213259 tracing:: info!( "🔍 Getting all container logs..." ) ;
0 commit comments