Skip to content

Commit 9e9f3a3

Browse files
authored
[browser] Emit hosting messages expected by debug proxy launcher (#118775)
1 parent 04a02a6 commit 9e9f3a3

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/mono/browser/debugger/BrowserDebugHost/DebugProxyHost.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public static async Task RunDevToolsProxyAsync(ProxyOptions options, string[] ar
5353
.ConfigureServices(services =>
5454
{
5555
services.AddSingleton(loggerFactory);
56-
services.AddLogging(configure => configure.AddSimpleConsole().AddFilter(null, LogLevel.Information));
5756
services.AddSingleton(Options.Create(options));
5857
services.AddRouting();
5958
})

src/mono/browser/debugger/BrowserDebugHost/Program.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using Microsoft.Extensions.Configuration;
88
using Microsoft.Extensions.DependencyInjection;
99
using 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

Comments
 (0)