@@ -4,7 +4,7 @@ const { spawn, execFileSync } = require('child_process');
44const fs = require ( 'fs' ) ;
55const os = require ( 'os' ) ;
66const path = require ( 'path' ) ;
7- const { waitForServer } = require ( './utils' ) ;
7+ const { waitForServer, logDebug } = require ( './utils' ) ;
88
99class ContainerBackend extends EventEmitter {
1010 constructor ( ) {
@@ -26,7 +26,7 @@ class ContainerBackend extends EventEmitter {
2626 } ) ;
2727 const host = ctx . trim ( ) ;
2828 if ( host ) {
29- console . log ( `Docker endpoint from context: ${ host } ` ) ;
29+ logDebug ( `Docker endpoint from context: ${ host } ` ) ;
3030 return host ;
3131 }
3232 } catch { /* fall through */ }
@@ -40,7 +40,7 @@ class ContainerBackend extends EventEmitter {
4040 for ( const pipe of pipes ) {
4141 try {
4242 execFileSync ( 'docker' , [ '-H' , pipe , 'info' ] , { stdio : 'ignore' , timeout : 5000 } ) ;
43- console . log ( `Docker endpoint found: ${ pipe } ` ) ;
43+ logDebug ( `Docker endpoint found: ${ pipe } ` ) ;
4444 return pipe ;
4545 } catch { /* try next */ }
4646 }
@@ -55,7 +55,7 @@ class ContainerBackend extends EventEmitter {
5555 for ( const sock of sockets ) {
5656 const sockPath = sock . replace ( 'unix://' , '' ) ;
5757 if ( fs . existsSync ( sockPath ) ) {
58- console . log ( `Docker socket found: ${ sock } ` ) ;
58+ logDebug ( `Docker socket found: ${ sock } ` ) ;
5959 return sock ;
6060 }
6161 }
@@ -144,7 +144,7 @@ class ContainerBackend extends EventEmitter {
144144 execFileSync ( this . containerEngine , [ 'image' , 'inspect' , image ] , {
145145 stdio : 'ignore' , env, timeout : 10000
146146 } ) ;
147- console . log ( `Image ${ image } found locally` ) ;
147+ logDebug ( `Image ${ image } found locally` ) ;
148148 return ;
149149 } catch {
150150 // Image not found locally
@@ -189,7 +189,7 @@ class ContainerBackend extends EventEmitter {
189189 buildProc . stdout . on ( 'data' , ( data ) => {
190190 const line = data . toString ( ) . trim ( ) ;
191191 if ( line ) {
192- console . log ( `[docker build] ${ line } ` ) ;
192+ logDebug ( `[docker build] ${ line } ` ) ;
193193 this . emit ( 'status' , {
194194 phase : 'downloading_runtime' ,
195195 message : line . substring ( 0 , 100 )
@@ -200,7 +200,7 @@ class ContainerBackend extends EventEmitter {
200200 const line = data . toString ( ) . trim ( ) ;
201201 stderr += line + '\n' ;
202202 if ( line ) {
203- console . log ( `[docker build] ${ line } ` ) ;
203+ logDebug ( `[docker build] ${ line } ` ) ;
204204 this . emit ( 'status' , {
205205 phase : 'downloading_runtime' ,
206206 message : line . substring ( 0 , 100 )
@@ -209,7 +209,7 @@ class ContainerBackend extends EventEmitter {
209209 } ) ;
210210 buildProc . on ( 'close' , ( code ) => {
211211 if ( code === 0 ) {
212- console . log ( `Built image: ${ image } ` ) ;
212+ logDebug ( `Built image: ${ image } ` ) ;
213213 resolve ( ) ;
214214 } else {
215215 reject ( new Error (
@@ -294,10 +294,10 @@ class ContainerBackend extends EventEmitter {
294294 message : `Using ${ this . containerEngine === 'docker' ? 'Docker' : 'Podman' } `
295295 } ) ;
296296
297- console . log ( `Starting container with ${ this . containerEngine } ...` ) ;
298- console . log ( `Image: ${ image } ` ) ;
299- console . log ( `App path: ${ appPath } ` ) ;
300- console . log ( `Port: ${ port } ` ) ;
297+ logDebug ( `Starting container with ${ this . containerEngine } ...` ) ;
298+ logDebug ( `Image: ${ image } ` ) ;
299+ logDebug ( `App path: ${ appPath } ` ) ;
300+ logDebug ( `Port: ${ port } ` ) ;
301301
302302 // Ensure image is available (build locally or pull from registry)
303303 await this . ensureImage ( image , config ) ;
@@ -344,7 +344,7 @@ class ContainerBackend extends EventEmitter {
344344 args . push ( image ) ;
345345
346346 return new Promise ( ( resolve , reject ) => {
347- console . log ( `Running: ${ this . containerEngine } ${ args . join ( ' ' ) } ` ) ;
347+ logDebug ( `Running: ${ this . containerEngine } ${ args . join ( ' ' ) } ` ) ;
348348
349349 const proc = spawn ( this . containerEngine , args , {
350350 stdio : [ 'ignore' , 'pipe' , 'pipe' ] ,
@@ -371,7 +371,7 @@ class ContainerBackend extends EventEmitter {
371371 }
372372
373373 this . containerId = stdout . trim ( ) . substring ( 0 , 12 ) ;
374- console . log ( `Container started: ${ this . containerId } ` ) ;
374+ logDebug ( `Container started: ${ this . containerId } ` ) ;
375375
376376 // Stream container logs while waiting for startup
377377 const logProc = spawn ( this . containerEngine , [ 'logs' , '-f' , this . containerId ] , {
@@ -383,23 +383,23 @@ class ContainerBackend extends EventEmitter {
383383 try {
384384 const msg = data . toString ( ) . trim ( ) ;
385385 if ( msg ) {
386- console . log ( `[container] ${ msg } ` ) ;
386+ logDebug ( `[container] ${ msg } ` ) ;
387387 this . emit ( 'status' , { phase : 'starting_server' , message : msg } ) ;
388388 }
389389 } catch { /* ignore write errors after shutdown */ }
390390 } ) ;
391391 logProc . stderr . on ( 'data' , ( data ) => {
392392 try {
393393 const msg = data . toString ( ) . trim ( ) ;
394- if ( msg ) console . log ( `[container] ${ msg } ` ) ;
394+ if ( msg ) logDebug ( `[container] ${ msg } ` ) ;
395395 } catch { /* ignore */ }
396396 } ) ;
397397
398398 // Wait for the server to be ready (longer timeout for container startup)
399399 waitForServer ( hostPort , { timeout : 120000 , interval : 1000 } )
400400 . then ( ( ) => {
401401 logProc . kill ( ) ;
402- console . log ( `Container server ready on http://localhost:${ hostPort } ` ) ;
402+ logDebug ( `Container server ready on http://localhost:${ hostPort } ` ) ;
403403 this . emit ( 'status' , { phase : 'server_ready' , message : 'Container ready' } ) ;
404404 resolve ( { port : hostPort } ) ;
405405 } )
@@ -440,7 +440,7 @@ class ContainerBackend extends EventEmitter {
440440 stop ( ) {
441441 if ( this . containerId && this . containerEngine ) {
442442 this . emit ( 'status' , { phase : 'stopping_server' , message : `Stopping container...` } ) ;
443- console . log ( `Stopping container ${ this . containerId } ...` ) ;
443+ logDebug ( `Stopping container ${ this . containerId } ...` ) ;
444444 try {
445445 execFileSync ( this . containerEngine , [ 'stop' , this . containerId ] , { stdio : 'ignore' , timeout : 10000 , env : this . getDockerEnv ( ) } ) ;
446446 } catch ( err ) {
0 commit comments