wabbajack/Wabbajack.App.Blazor/Components/VirtualLogger.razor

24 lines
676 B
Plaintext
Raw Normal View History

2022-01-21 13:54:22 +00:00
@using NLog
@using NLog.Targets
2022-01-20 08:34:38 +00:00
@namespace Wabbajack.App.Blazor.Components
<div id="virtual-logger">
2022-01-21 13:54:22 +00:00
<Virtualize Items="@Logs" Context="logItem" OverscanCount="3">
<span @key="logItem">@logItem</span>
</Virtualize>
</div>
@code {
// TODO: [Low] More parameters to customise the logger. E.g. Reverse order.
// TODO: [High] Find a way to auto-scroll. (JS interop?)
2022-01-21 13:54:22 +00:00
private MemoryTarget? _memoryTarget;
private ICollection<string> Logs => _memoryTarget?.Logs ?? Array.Empty<string>();
2022-01-21 13:54:22 +00:00
protected override void OnInitialized()
{
_memoryTarget = LogManager.Configuration.FindTargetByName<MemoryTarget>("ui");
}
}