diff options
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/LogView.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/LogView.razor | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor index 2f83cb2..d541b82 100644 --- a/MatrixRoomUtils.Web/Shared/LogView.razor +++ b/MatrixRoomUtils.Web/Shared/LogView.razor @@ -1,42 +1,41 @@ -@using System.Text -@if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) { - <u>Logs</u> - <br/> - <pre> - @_stringBuilder - </pre> -} - -@code { - StringBuilder _stringBuilder = new(); - - protected override async Task OnInitializedAsync() { - await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); - if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) { - Console.WriteLine("Console logging disabled!"); - var _sw = new StringWriter(); - Console.SetOut(_sw); - Console.SetError(_sw); - return; - } - if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) return; - //intecept stdout with textwriter to get logs - var sw = new StringWriter(_stringBuilder); - Console.SetOut(sw); - Console.SetError(sw); - //keep updated - var length = 0; - Task.Run(async () => { - while (true) { - await Task.Delay(100); - if (_stringBuilder.Length != length) { - StateHasChanged(); - length = _stringBuilder.Length; - } - } - // ReSharper disable once FunctionNeverReturns - This is intentional behavior - }); - await base.OnInitializedAsync(); - } - -} \ No newline at end of file +@* @using System.Text *@ +@* @if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) { *@ +@* <u>Logs</u> *@ +@* <br/> *@ +@* <pre> *@ +@* @_stringBuilder *@ +@* </pre> *@ +@* } *@ +@* *@ +@* @code { *@ +@* StringBuilder _stringBuilder = new(); *@ +@* *@ +@* protected override async Task OnInitializedAsync() { *@ +@* if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableConsoleLogging) { *@ +@* Console.WriteLine("Console logging disabled!"); *@ +@* var _sw = new StringWriter(); *@ +@* Console.SetOut(_sw); *@ +@* Console.SetError(_sw); *@ +@* return; *@ +@* } *@ +@* if (!LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) return; *@ +@* //intecept stdout with textwriter to get logs *@ +@* var sw = new StringWriter(_stringBuilder); *@ +@* Console.SetOut(sw); *@ +@* Console.SetError(sw); *@ +@* //keep updated *@ +@* var length = 0; *@ +@* Task.Run(async () => { *@ +@* while (true) { *@ +@* await Task.Delay(100); *@ +@* if (_stringBuilder.Length != length) { *@ +@* StateHasChanged(); *@ +@* length = _stringBuilder.Length; *@ +@* } *@ +@* } *@ +@* // ReSharper disable once FunctionNeverReturns - This is intentional behavior *@ +@* }); *@ +@* await base.OnInitializedAsync(); *@ +@* } *@ +@* *@ +@* } *@ \ No newline at end of file |