You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: #5494
Context: #5241Fixes: #5435
We added `--dsrouter` switch to both `dotnet-trace` and `dotnet-gcdump`,
which runs `dotnet-dsrouter` as a child process.
Many of `dotnet-dsrouter`'s console messages are pretty useful for
developers, but we are simply ignoring them:
private static async Task ReadAndIgnoreAllStreamAsync(StreamReader
streamToIgnore, CancellationToken cancelToken)
{
Memory<char> memory = new char[4096];
while (await streamToIgnore.ReadAsync(memory,
cancelToken).ConfigureAwait(false) != 0)
{
}
}
To make this a bit more useful, we now log the output to either
`Console.Out` or `Console.Error` where appropriate.
If we simply did:
string line;
while ((line = await
streamToRead.ReadLineAsync(cancelToken).ConfigureAwait(false)) != null)
{
output.WriteLine(line);
}
This would work fine, but we'd lose all coloring.
`dotnet-dsrouter` uses `SimpleConsoleFormatter` to colorize its output:
https://github.com/dotnet/runtime/blob/aadcceeb03ce0ecbc2ad645de0feb10189daa64c/src/libraries/Microsoft.Extensions.Logging.Console/src/SimpleConsoleFormatter.cs#L163-L199
So, for now, a very simple solution is to check the known prefixes and
add coloring. This looks to have a pretty good result.
I also dropped the duplicate message:
WARNING: dotnet-dsrouter is a development tool not intended for
production environments.
Now that we print all of `dotnet-dsrouter`'s output, we can handle this
case and color it yellow.
<img width="2524" height="582" alt="image"
src="https://github.com/user-attachments/assets/4924ec93-c616-4511-83f8-f318f4ce4471"
/>
0 commit comments