33using System . IO ;
44using System . Linq ;
55using System . Threading . Tasks ;
6+ using Microsoft . AspNetCore . NodeServices . Util ;
67
78namespace Microsoft . AspNetCore . NodeServices . HostingModels
89{
@@ -26,13 +27,18 @@ public abstract class OutOfProcessNodeInstance : INodeInstance
2627 private readonly Process _nodeProcess ;
2728 private bool _nodeProcessNeedsRestart ;
2829 private readonly string [ ] _watchFileExtensions ;
30+ private INodeInstanceOutputLogger _nodeInstanceOutputLogger ;
2931
3032 public OutOfProcessNodeInstance (
3133 string entryPointScript ,
3234 string projectPath ,
3335 string [ ] watchFileExtensions ,
34- string commandLineArguments )
36+ string commandLineArguments ,
37+ INodeInstanceOutputLogger nodeOutputLogger )
3538 {
39+ _nodeInstanceOutputLogger = nodeOutputLogger ;
40+ if ( _nodeInstanceOutputLogger == null )
41+ _nodeInstanceOutputLogger = new ConsoleNodeInstanceOutputLogger ( ) ;
3642 _entryPointScript = new StringAsTempFile ( entryPointScript ) ;
3743
3844 var startInfo = PrepareNodeProcessStartInfo ( _entryPointScript . FileName , projectPath , commandLineArguments ) ;
@@ -106,12 +112,12 @@ protected virtual ProcessStartInfo PrepareNodeProcessStartInfo(
106112
107113 protected virtual void OnOutputDataReceived ( string outputData )
108114 {
109- Console . WriteLine ( "[Node] " + outputData ) ;
115+ _nodeInstanceOutputLogger . LogOutputData ( outputData ) ;
110116 }
111117
112118 protected virtual void OnErrorDataReceived ( string errorData )
113119 {
114- Console . WriteLine ( "[Node] " + errorData ) ;
120+ _nodeInstanceOutputLogger . LogErrorData ( errorData ) ;
115121 }
116122
117123 protected virtual void Dispose ( bool disposing )
0 commit comments