File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88/**
99 * Test logger that provides structured output for test execution.
10- * Logs are written immediately to stdout, errors to stderr .
10+ * Uses synchronous writes to prevent interleaving .
1111 */
1212class TestLogger {
1313 /**
14- * Log a message to stdout
14+ * Log a message to stdout using synchronous write
1515 */
1616 log ( message : string ) : void {
17- console . log ( message ) ;
17+ process . stdout . write ( message + '\n' ) ;
1818 }
1919
2020 /**
2121 * Log an error message to stderr with clear separation
22+ * Uses a single synchronous write to prevent interleaving
2223 */
2324 error ( message : string , error ?: any ) : void {
24- // Write to stderr with clear separation
25- process . stderr . write ( '\n' + '=' . repeat ( 80 ) + '\n' ) ;
26- process . stderr . write ( `[ERROR] ${ message } \n` ) ;
25+ // Build the entire error message as a single string
26+ let errorOutput = '\n' + '=' . repeat ( 80 ) + '\n' ;
27+ errorOutput += `[ERROR] ${ message } \n` ;
28+
2729 if ( error ) {
2830 if ( error . stack ) {
29- process . stderr . write ( error . stack + '\n' ) ;
31+ errorOutput += error . stack + '\n' ;
3032 } else {
31- process . stderr . write ( String ( error ) + '\n' ) ;
33+ errorOutput += String ( error ) + '\n' ;
3234 }
3335 }
34- process . stderr . write ( '=' . repeat ( 80 ) + '\n\n' ) ;
36+
37+ errorOutput += '=' . repeat ( 80 ) + '\n\n' ;
38+
39+ // Write the entire error message in one synchronous operation
40+ process . stderr . write ( errorOutput ) ;
3541 }
3642
3743 /**
You can’t perform that action at this time.
0 commit comments