about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/LogView.razor
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-01 02:43:32 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-01 02:43:32 +0200
commitdf9031c47f8e97d8e2df3177093271a458f27267 (patch)
tree4e81dec4048c6e76a928ef69c905560d7c173fdf /MatrixRoomUtils.Web/Shared/LogView.razor
downloadMatrixUtils-df9031c47f8e97d8e2df3177093271a458f27267.tar.xz
Initial commit
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/LogView.razor')
-rw-r--r--MatrixRoomUtils.Web/Shared/LogView.razor31
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