-
Notifications
You must be signed in to change notification settings - Fork 42
Add filter, virtualization, and export UI to DebugLogModal and unify file save #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jschick04
wants to merge
1
commit into
main
Choose a base branch
from
jschick/debug-log-filters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
995 changes: 995 additions & 0 deletions
995
src/EventLogExpert.Components.Tests/Modals/DebugLogModalTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
src/EventLogExpert.Components.Tests/TestUtils/Constants/Constants.DebugLog.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // // Copyright (c) Microsoft Corporation. | ||
| // // Licensed under the MIT License. | ||
|
|
||
| namespace EventLogExpert.Components.Tests.TestUtils.Constants; | ||
|
|
||
| public sealed partial class Constants | ||
| { | ||
| public const string DebugLogErrorMessage = "Error message"; | ||
| public const string DebugLogFirstMessage = "First message"; | ||
| public const string DebugLogSecondMessage = "Second message"; | ||
| public const string DebugLogTestMessage = "Test message"; | ||
| public const int DebugLogTestThreadId = 12; | ||
| public const string DebugLogTestTimestamp = "2026-04-29T07:53:20.9321852-04:00"; | ||
| public const string DebugLogThirdMessage = "Third message"; | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/EventLogExpert.Components.Tests/TestUtils/DebugLogUtils.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // // Copyright (c) Microsoft Corporation. | ||
| // // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace EventLogExpert.Components.Tests.TestUtils; | ||
|
|
||
| public static class DebugLogUtils | ||
| { | ||
| public static string BuildLine(LogLevel level, string message) => | ||
| $"[{Constants.Constants.DebugLogTestTimestamp}] [{Constants.Constants.DebugLogTestThreadId}] [{level}] {message}"; | ||
|
|
||
| public static async IAsyncEnumerable<string> ToAsyncEnumerable(IEnumerable<string> lines) | ||
| { | ||
| foreach (var line in lines) | ||
| { | ||
| yield return line; | ||
|
|
||
| await Task.Yield(); | ||
| } | ||
| } | ||
|
|
||
| public static async IAsyncEnumerable<string> YieldThenThrow(IEnumerable<string> lines, Exception exception) | ||
| { | ||
| foreach (var line in lines) | ||
| { | ||
| yield return line; | ||
|
|
||
| await Task.Yield(); | ||
| } | ||
|
|
||
| throw exception; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,107 @@ | ||
| @inherits ModalBase<bool> | ||
| @using EventLogExpert.UI | ||
| @using Microsoft.Extensions.Logging | ||
|
|
||
| <ModalChrome AriaLabel="Debug Log" | ||
| CloseLabel="Exit" | ||
| Footer="FooterPreset.CloseOnly" | ||
| Height="60%" | ||
| InlineAlert="@CurrentInlineAlert" | ||
| MinWidth="50rem" | ||
| MaxWidth="100rem" | ||
| MinWidth="100rem" | ||
|
jschick04 marked this conversation as resolved.
jschick04 marked this conversation as resolved.
jschick04 marked this conversation as resolved.
|
||
| OnClose="OnCancelAsync" | ||
| OnDialogClosedByUser="HandleDialogClosedByUserAsync" | ||
| OnInlineAlertResolved="HandleInlineAlertResolvedAsync" | ||
| @ref="ChromeRef"> | ||
| <ChildContent> | ||
| <div aria-busy="@(_hasLoaded ? "false" : "true")" aria-label="Debug log entries" aria-live="polite" class="flex-column-scroll" role="log"> | ||
| @if (_data.Count > 0) | ||
| <div aria-label="Filters" class="debug-log-filter-bar" role="group"> | ||
| <label>Level</label> | ||
| <ValueSelect AriaLabel="Level operator" | ||
| CssClass="input filter-dropdown" | ||
| T="FilterEvaluator" | ||
| Value="_levelOperator" | ||
| ValueChanged="HandleLevelOperatorChanged" | ||
| ToStringFunc="@(x => x.ToFullString())"> | ||
| <ValueSelectItem T="FilterEvaluator" Value="FilterEvaluator.Equals" /> | ||
| <ValueSelectItem T="FilterEvaluator" Value="FilterEvaluator.NotEqual" /> | ||
| <ValueSelectItem T="FilterEvaluator" Value="FilterEvaluator.MultiSelect" /> | ||
| </ValueSelect> | ||
| @if (_levelOperator == FilterEvaluator.MultiSelect) | ||
| { | ||
| @for (var i = _data.Count - 1; i >= 0; i--) | ||
| { | ||
| <text>@_data[i]</text> | ||
| <br /> | ||
| } | ||
| <ValueSelect AriaLabel="Levels" | ||
| CssClass="input filter-dropdown debug-log-level-multi" | ||
| EmptyText="All" | ||
| IsMultiSelect | ||
| T="LogLevel" | ||
| Values="_multiLevels" | ||
| ValuesChanged="HandleMultiLevelsChanged" | ||
| ToStringFunc="@(x => x.ToString())"> | ||
| <ValueSelectItem T="LogLevel" ClearItem>All</ValueSelectItem> | ||
|
jschick04 marked this conversation as resolved.
jschick04 marked this conversation as resolved.
jschick04 marked this conversation as resolved.
|
||
| @foreach (var level in s_logLevels) | ||
| { | ||
| <ValueSelectItem T="LogLevel" Value="level" /> | ||
| } | ||
| </ValueSelect> | ||
| } | ||
| else if (_hasLoaded) | ||
| else | ||
| { | ||
| <text>Log is Empty...</text> | ||
| <ValueSelect AriaLabel="Level" | ||
| CssClass="input filter-dropdown" | ||
| T="LogLevel?" | ||
| Value="_singleLevel" | ||
| ValueChanged="HandleSingleLevelChanged" | ||
| ToStringFunc="@(x => x?.ToString() ?? "All")"> | ||
| <ValueSelectItem T="LogLevel?" ClearItem>All</ValueSelectItem> | ||
| @foreach (var level in s_logLevels) | ||
| { | ||
| <ValueSelectItem T="LogLevel?" Value="level" /> | ||
| } | ||
| </ValueSelect> | ||
| } | ||
| <input aria-label="Filter messages" | ||
| class="input debug-log-text-filter" | ||
| @oninput="HandleStringFilterInput" | ||
| placeholder="Filter messages..." | ||
| type="text" | ||
| value="@_pendingStringFilter" /> | ||
| </div> | ||
| <div aria-busy="@(_hasLoaded ? "false" : "true")" aria-label="Debug log entries" class="debug-log-viewport" role="region" tabindex="0"> | ||
|
jschick04 marked this conversation as resolved.
|
||
| <Virtualize Items="_displayedView" Context="line" ItemSize="@RowHeightPx" OverscanCount="20"> | ||
| <ItemContent> | ||
| <div class="debug-log-row">@line</div> | ||
|
jschick04 marked this conversation as resolved.
|
||
| </ItemContent> | ||
|
jschick04 marked this conversation as resolved.
jschick04 marked this conversation as resolved.
|
||
| <EmptyContent> | ||
| @if (_hasLoaded) | ||
| { | ||
| <span>@(_entries.Count == 0 ? "Log is Empty..." : "No entries match filters.")</span> | ||
| } | ||
| </EmptyContent> | ||
| </Virtualize> | ||
| </div> | ||
| </ChildContent> | ||
| <ExtraFooterContent> | ||
| <div class="button-group"> | ||
| <button class="button" @onclick="Refresh" type="button">Refresh</button> | ||
| <button class="button" @onclick="Clear" type="button">Clear</button> | ||
| <div class="debug-log-footer"> | ||
| <div class="debug-log-footer-actions debug-log-footer-left"> | ||
| <button class="button" | ||
| disabled="@(!_hasLoaded || _filteredEntryCount == 0)" | ||
| @onclick="HandleExportAsync" | ||
| type="button"> | ||
| Export | ||
| </button> | ||
| <button class="button" | ||
| disabled="@(!_hasLoaded || _filteredEntryCount == 0)" | ||
| @onclick="HandleCopyAsync" | ||
| type="button"> | ||
| Copy | ||
| </button> | ||
| </div> | ||
| <span aria-atomic="true" aria-live="polite" class="debug-log-footer-counter" role="status"> | ||
| @($"{_filteredEntryCount:N0} of {_entries.Count:N0} {(_entries.Count == 1 ? "entry" : "entries")}") | ||
| </span> | ||
| <div class="debug-log-footer-actions debug-log-footer-right"> | ||
| <button class="button" @onclick="Refresh" type="button">Refresh</button> | ||
| <button class="button" @onclick="Clear" type="button">Clear</button> | ||
| </div> | ||
| </div> | ||
| </ExtraFooterContent> | ||
| </ModalChrome> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.