@@ -64,6 +64,7 @@ internal class ConsoleCoordinator : IConsoleCoordinator, IProgressDisplay
6464
6565 // Logger for output
6666 private ILogger ? _outputLogger ;
67+ private readonly IOutputCoordinator _outputCoordinator ;
6768
6869 public ConsoleCoordinator (
6970 IBuildSystemFormatterProvider formatterProvider ,
@@ -72,7 +73,8 @@ public ConsoleCoordinator(
7273 IOptions < PipelineOptions > options ,
7374 ILoggerFactory loggerFactory ,
7475 IBuildSystemDetector buildSystemDetector ,
75- IServiceProvider serviceProvider )
76+ IServiceProvider serviceProvider ,
77+ IOutputCoordinator outputCoordinator )
7678 {
7779 _formatterProvider = formatterProvider ;
7880 _resultsPrinter = resultsPrinter ;
@@ -81,6 +83,7 @@ public ConsoleCoordinator(
8183 _loggerFactory = loggerFactory ;
8284 _buildSystemDetector = buildSystemDetector ;
8385 _serviceProvider = serviceProvider ;
86+ _outputCoordinator = outputCoordinator ;
8487 _unattributedBuffer = new ModuleOutputBuffer ( "Pipeline" , typeof ( void ) ) ;
8588 }
8689
@@ -221,8 +224,12 @@ public async Task<IProgressSession> BeginProgressAsync(
221224 this ,
222225 modules ,
223226 _options ,
227+ _loggerFactory ,
224228 cancellationToken ) ;
225229
230+ // Wire up the progress controller for output coordination
231+ _outputCoordinator . SetProgressController ( session ) ;
232+
226233 _activeSession = session ;
227234
228235 // Start the progress display
@@ -238,6 +245,7 @@ internal void EndProgressPhase()
238245 {
239246 lock ( _phaseLock )
240247 {
248+ _outputCoordinator . SetProgressController ( NoOpProgressController . Instance ) ;
241249 _isProgressActive = false ;
242250 _activeSession = null ;
243251 }
@@ -255,38 +263,22 @@ public IModuleOutputBuffer GetModuleBuffer(Type moduleType)
255263 /// <inheritdoc />
256264 public void FlushModuleOutput ( )
257265 {
266+ // Output is now flushed immediately when modules complete.
267+ // This method remains for API compatibility but only flushes
268+ // unattributed output (pipeline-level logs).
258269 if ( _originalConsoleOut == null )
259270 {
260- throw new InvalidOperationException ( "ConsoleCoordinator is not installed." ) ;
271+ return ; // Not installed, nothing to flush
261272 }
262273
263274 var formatter = _formatterProvider . GetFormatter ( ) ;
264275
265- // Flush unattributed output first (if any)
276+ // Flush unattributed output (if any)
266277 if ( _unattributedBuffer . HasOutput )
267278 {
268279 var unattributedLogger = _outputLogger ?? _loggerFactory . CreateLogger ( "ModularPipelines.Output" ) ;
269280 _unattributedBuffer . FlushTo ( _originalConsoleOut , formatter , unattributedLogger ) ;
270281 }
271-
272- // Flush module buffers in completion order
273- var orderedBuffers = _moduleBuffers . Values
274- . Where ( b => b . HasOutput )
275- . OrderBy ( b => b . CompletedAtUtc ?? DateTime . MaxValue )
276- . ToList ( ) ;
277-
278- foreach ( var buffer in orderedBuffers )
279- {
280- // Resolve the registered ILogger<T> from DI to use any custom loggers injected by tests
281- var loggerType = typeof ( ILogger < > ) . MakeGenericType ( buffer . ModuleType ) ;
282- var moduleLogger = ( ILogger ) _serviceProvider . GetService ( loggerType )
283- ?? _loggerFactory . CreateLogger ( buffer . ModuleType ) ;
284- buffer . FlushTo ( _originalConsoleOut , formatter , moduleLogger ) ;
285- }
286-
287- // Clear buffers after flush to release memory
288- // This prevents accumulation in long-running pipelines
289- _moduleBuffers . Clear ( ) ;
290282 }
291283
292284 /// <inheritdoc />
0 commit comments