blob: fbe52649fbea8a69d7bd13d74b0cc9723ebf30ec (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
@using System.Text
<u>Logs</u><br/>
<pre>
@sb
</pre>
@code {
StringBuilder sb = new();
protected override void OnInitialized()
{
//intecept stdout with textwriter to get logs
var sw = new StringWriter(sb);
Console.SetOut(sw);
Console.SetError(sw);
//keep updated
int length = 0;
Task.Run(async () =>
{
while (true)
{
await Task.Delay(100);
if (sb.Length != length)
{
StateHasChanged();
length = sb.Length;
}
}
});
base.OnInitialized();
}
}
|