diff options
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/LogView.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/LogView.razor | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor new file mode 100644 index 0000000..fbe5264 --- /dev/null +++ b/MatrixRoomUtils.Web/Shared/LogView.razor @@ -0,0 +1,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(); + } +} \ No newline at end of file |