Commit 7906474
authored
[dsrouter] log redirected console output (#5524)
Context: #5494
Context: #5241
Fixes: #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"
/>1 parent fcaeae3 commit 7906474
File tree
2 files changed
+86
-9
lines changed- src/Tools/Common
- Commands
2 files changed
+86
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
32 | 113 | | |
33 | 114 | | |
34 | 115 | | |
| |||
69 | 150 | | |
70 | 151 | | |
71 | 152 | | |
72 | | - | |
73 | | - | |
| 153 | + | |
| 154 | + | |
74 | 155 | | |
75 | 156 | | |
76 | 157 | | |
| |||
0 commit comments