[OPTIMIZING]

This commit is contained in:
max
2025-09-10 02:55:06 +02:00
parent 03631cd0c8
commit ef6ca0ee07
4 changed files with 8 additions and 14 deletions

View File

@@ -43,18 +43,11 @@
<MudText Typo="Typo.caption">@($"{_serviceEvents.Count}/{VisibleEventCapacity} events")</MudText>
</MudStack>
<div class="console-container">
@foreach (var serviceEvent in _serviceEvents)
{
<Virtualize Items="_serviceEvents" Context="serviceEvent">
<div class="log-line">
<span>@serviceEvent.Date</span>
<span>|</span>
<span class="@GetLogClass(serviceEvent)">@serviceEvent.Severity</span>
<span>|</span>
<span style="color: #4d69f1">@serviceEvent.Source</span>
<span>-</span>
<span style="color: #d4d4d4">@serviceEvent.Message</span>
@($"{serviceEvent.Date:HH:mm:ss} | {serviceEvent.Severity} | {serviceEvent.Source} - {serviceEvent.Message}")
</div>
}
</Virtualize>
</div>
</MudPaper>

View File

@@ -22,10 +22,11 @@ public class CircularBuffer <T>
Capacity = capacity;
_buffer = new T[Capacity];
_channel = Channel.CreateUnbounded<T>(new UnboundedChannelOptions
_channel = Channel.CreateBounded<T>(new BoundedChannelOptions(Capacity)
{
SingleReader = false,
SingleWriter = false,
FullMode = BoundedChannelFullMode.DropOldest
});
}

View File

@@ -60,7 +60,7 @@ public abstract class ExtendedBackgroundService : BackgroundService
}
}
protected void LogEvent(string message, LogSeverity severity = LogSeverity.Info) => ProgressEvents.Add(new ServiceEvent(Name, message, DateTime.UtcNow, severity));
protected void LogEvent(string message, LogSeverity severity = LogSeverity.Info) => ProgressEvents.Add(new ServiceEvent(string.Intern(Name), message, DateTime.UtcNow, severity));
public void Pause()
{
@@ -103,4 +103,4 @@ public enum ServiceState
Paused
}
public record ServiceEvent(string Source, string Message, DateTime Date, LogSeverity Severity);
public record struct ServiceEvent(string Source, string Message, DateTime Date, LogSeverity Severity);

View File

@@ -21,7 +21,7 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
using var scope = scopeFactory.CreateScope();
_libraryService = scope.ServiceProvider.GetRequiredService<ILibraryService>();
LogEvent("Initializing service...");
Pause();
//Pause();
}
protected override async Task ExecuteServiceAsync(CancellationToken stoppingToken)