mirror of
https://github.com/alexhopeoconnor/dnsmasq-webui.git
synced 2026-10-03 22:12:00 +10:00
- Add real-time app logs via SignalR (log level, category filters) - Add filters modal with restore defaults; sentinel for empty arrays - Add client settings: max lines and auto-scroll per log panel - Improve NavMenu: align settings + hamburger, smaller mobile logo - LogsService, LogsHub, LoggingController, AppLogsLoggerProvider - Persist log level and filters to appsettings.Overrides.json
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using System.Threading.Channels;
|
|
using DnsmasqWebUI.Infrastructure.Logging;
|
|
using DnsmasqWebUI.Infrastructure.Services;
|
|
using DnsmasqWebUI.Infrastructure.Services.Abstractions;
|
|
using DnsmasqWebUI.Models.Config;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace DnsmasqWebUI.Extensions;
|
|
|
|
/// <summary>
|
|
/// App logs setup: buffer, channel, and provider.
|
|
/// Encapsulates the wiring that must run before the DI container exists (ILoggerProvider is created during host configuration).
|
|
/// Log level and excluded category prefixes are configured via appsettings.Overrides.json (config source with reloadOnChange).
|
|
/// </summary>
|
|
public static class LoggingBuilderExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds the app logs provider (forwards ILogger output to SignalR) and registers buffer and channel.
|
|
/// Call before <c>builder.Build()</c>.
|
|
/// </summary>
|
|
public static ILoggingBuilder AddAppLogs(this ILoggingBuilder logging, IConfiguration configuration)
|
|
{
|
|
var services = logging.Services;
|
|
|
|
var buffer = new AppLogsBuffer();
|
|
var pushChannel = Channel.CreateBounded<byte>(new BoundedChannelOptions(1) { FullMode = BoundedChannelFullMode.DropOldest });
|
|
|
|
services.AddSingleton(pushChannel);
|
|
services.AddSingleton<IAppLogsBuffer>(buffer);
|
|
services.AddSingleton<ILogsService, LogsService>();
|
|
|
|
logging.AddProvider(new AppLogsLoggerProvider(buffer, pushChannel, configuration));
|
|
|
|
return logging;
|
|
}
|
|
}
|