wabbajack/Wabbajack.App.Blazor/Components/VirtualLogger.razor
2022-01-21 14:54:22 +01:00

24 lines
676 B
Plaintext

@using NLog
@using NLog.Targets
@namespace Wabbajack.App.Blazor.Components
<div id="virtual-logger">
<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?)
private MemoryTarget? _memoryTarget;
private ICollection<string> Logs => _memoryTarget?.Logs ?? Array.Empty<string>();
protected override void OnInitialized()
{
_memoryTarget = LogManager.Configuration.FindTargetByName<MemoryTarget>("ui");
}
}