@@ -62,7 +62,9 @@ const logFormat =
6262
6363// Use the custom format
6464app . use ( trackBytes ) ;
65- app . use ( morgan ( logFormat ) ) ;
65+ if ( process . env . LOGGING === 'true' ) {
66+ app . use ( morgan ( logFormat ) ) ;
67+ }
6668
6769const port = 3001 ;
6870const spdyPort = 3002 ;
@@ -371,7 +373,9 @@ app.post('/echo', async (req, res) => {
371373 const timestamp = new Date ( ) . toISOString ( ) ;
372374 totalBytesReceived += chunk . length ;
373375 if ( debugMode ) {
374- console . log ( `${ logPrefix } - RECEIVED chunk ${ chunk . length } bytes, total ${ totalBytesReceived } bytes at ${ timestamp } ` ) ;
376+ console . log (
377+ `${ logPrefix } - RECEIVED chunk ${ chunk . length } bytes, total ${ totalBytesReceived } bytes at ${ timestamp } ` ,
378+ ) ;
375379 }
376380
377381 this . push ( chunk ) ;
@@ -383,7 +387,7 @@ app.post('/echo', async (req, res) => {
383387 console . log ( `${ logPrefix } - FINISHED` ) ;
384388 }
385389 callback ( ) ;
386- }
390+ } ,
387391 } ) ;
388392
389393 // Pipe the req body to the response with back pressure
@@ -465,7 +469,7 @@ app.post('/double-echo', async (req, res) => {
465469
466470app . post ( '/half-echo' , async ( req , res ) => {
467471 const contentType = req . get ( 'Content-Type' ) ;
468-
472+
469473 if ( contentType ) {
470474 res . set ( 'Content-Type' , contentType ) ;
471475 }
@@ -492,7 +496,7 @@ app.post('/half-echo', async (req, res) => {
492496 const halfLength = chunk . length >> 1 ;
493497 this . push ( chunk . slice ( 0 , halfLength ) , 'binary' ) ;
494498 callback ( ) ;
495- }
499+ } ,
496500 } ) ;
497501
498502 // Pipe through halver transform then to response
0 commit comments