77using Microsoft . Extensions . Configuration ;
88using Microsoft . Extensions . DependencyInjection ;
99using Microsoft . Extensions . Logging ;
10+ using Microsoft . Extensions . Logging . Abstractions ;
11+ using Microsoft . Extensions . Logging . Console ;
1012
1113#nullable enable
1214
@@ -23,16 +25,24 @@ public static async Task Main(string[] args)
2325
2426 using ILoggerFactory loggerFactory = LoggerFactory . Create ( builder =>
2527 {
26- builder . AddSimpleConsole ( options =>
27- {
28- options . TimestampFormat = "[HH:mm:ss] " ;
29- } )
30- . AddFilter ( "DevToolsProxy" , LogLevel . Information )
31- . AddFilter ( "FirefoxMonoProxy" , LogLevel . Information )
32- . AddFilter ( null , LogLevel . Warning ) ;
28+ builder
29+ . AddConsole ( options => options . FormatterName = "messageOnly" ) // Emit messages as expected by DebugProxyLauncher.cs
30+ . AddConsoleFormatter < MessageOnlyFormatter , ConsoleFormatterOptions > ( )
31+ . AddFilter ( "Microsoft.Hosting.Lifetime" , LogLevel . Information )
32+ . AddFilter ( "DevToolsProxy" , LogLevel . Information )
33+ . AddFilter ( "FirefoxMonoProxy" , LogLevel . Information )
34+ . AddFilter ( null , LogLevel . Warning ) ;
3335 } ) ;
3436
3537 await DebugProxyHost . RunDebugProxyAsync ( options , args , loggerFactory , CancellationToken . None ) ;
3638 }
3739 }
40+
41+ public class MessageOnlyFormatter : ConsoleFormatter
42+ {
43+ public MessageOnlyFormatter ( ) : base ( "messageOnly" ) { }
44+
45+ public override void Write < TState > ( in LogEntry < TState > logEntry , IExternalScopeProvider ? scopeProvider , TextWriter textWriter )
46+ => textWriter . WriteLine ( logEntry . Formatter ( logEntry . State , logEntry . Exception ) ) ;
47+ }
3848}
0 commit comments