diff options
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/LogView.razor')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/LogView.razor | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/MatrixRoomUtils.Web/Shared/LogView.razor b/MatrixRoomUtils.Web/Shared/LogView.razor index f60f271..80fd355 100644 --- a/MatrixRoomUtils.Web/Shared/LogView.razor +++ b/MatrixRoomUtils.Web/Shared/LogView.razor @@ -1,13 +1,27 @@ @using System.Text -<u>Logs</u><br/> -<pre> - @_stringBuilder -</pre> +@if (LocalStorageWrapper.Settings.DeveloperSettings.EnableLogViewers) +{ + <u>Logs</u> + <br/> + <pre> + @_stringBuilder + </pre> +} @code { StringBuilder _stringBuilder = new(); - protected override void OnInitialized() + 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); @@ -27,6 +41,6 @@ } // ReSharper disable once FunctionNeverReturns - This is intentional behavior }); - base.OnInitialized(); + await base.OnInitializedAsync(); } } \ No newline at end of file |