From df9031c47f8e97d8e2df3177093271a458f27267 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 1 May 2023 02:43:32 +0200 Subject: Initial commit --- MatrixRoomUtils.Web/Shared/LogView.razor | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 MatrixRoomUtils.Web/Shared/LogView.razor (limited to 'MatrixRoomUtils.Web/Shared/LogView.razor') 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 +Logs
+
+    @sb
+
+ +@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 -- cgit 1.4.1