diff --git a/src/Spice86.Core/Emulator/Devices/Video/Renderer.cs b/src/Spice86.Core/Emulator/Devices/Video/Renderer.cs
index f6c1550ea9..d11e12ee05 100644
--- a/src/Spice86.Core/Emulator/Devices/Video/Renderer.cs
+++ b/src/Spice86.Core/Emulator/Devices/Video/Renderer.cs
@@ -7,7 +7,7 @@ namespace Spice86.Core.Emulator.Devices.Video;
using Spice86.Core.Emulator.Devices.Video.Registers;
using Spice86.Core.Emulator.Devices.Video.Registers.Graphics;
using Spice86.Core.Emulator.Memory;
-using Spice86.Logging;
+using Spice86.Shared.Interfaces;
using ClockSelect = Registers.General.MiscellaneousOutput.ClockSelectValue;
@@ -74,7 +74,7 @@ public class Renderer : IVgaRenderer {
/// Shared blink state for text-mode attribute blinking.
/// The logger service implementation.
/// The 256-color scanline renderer selected for the current CPU.
- public Renderer(IMemory memory, IVideoState state, VgaBlinkState blinkState, LoggerService loggerService, IVgaRenderer256Color renderer256Color) {
+ public Renderer(IMemory memory, IVideoState state, VgaBlinkState blinkState, ILoggerService loggerService, IVgaRenderer256Color renderer256Color) {
_state = state;
_blinkState = blinkState;
_renderer256Color = renderer256Color;
diff --git a/src/Spice86.Logging/LoggerService.cs b/src/Spice86.Logging/LoggerService.cs
index d921ef38b9..0b75af8695 100644
--- a/src/Spice86.Logging/LoggerService.cs
+++ b/src/Spice86.Logging/LoggerService.cs
@@ -14,7 +14,6 @@ public class LoggerService : ILoggerService, IDisposable {
private static readonly object?[] EmptyProperties = [];
- private LoggerConfiguration _loggerConfiguration;
private Logger? _logger;
private LoggingLevelSwitch _logLevelSwitch;
private bool _disposed;
@@ -25,8 +24,6 @@ public class LoggerService : ILoggerService, IDisposable {
public LoggerService() {
_logLevelSwitch = new LoggingLevelSwitch();
LoggerPropertyBag = new LoggerPropertyBag();
- _loggerConfiguration = CreateLoggerConfiguration();
- _loggerConfiguration.MinimumLevel.ControlledBy(_logLevelSwitch);
}
///
@@ -34,7 +31,6 @@ public LoggingLevelSwitch LogLevelSwitch {
get => _logLevelSwitch;
set {
_logLevelSwitch = value ?? throw new ArgumentNullException(nameof(value));
- _loggerConfiguration.MinimumLevel.ControlledBy(_logLevelSwitch);
ResetLogger();
}
}
@@ -49,28 +45,14 @@ public LoggingLevelSwitch LogLevelSwitch {
public LoggerConfiguration CreateLoggerConfiguration() {
LoggerConfiguration configuration = new LoggerConfiguration()
.Enrich.FromLogContext()
- .Enrich.With(new LoggerPropertyBagEnricher(LoggerPropertyBag))
- .WriteTo.Async(conf => conf.Console(outputTemplate: LogFormat))
- .WriteTo.Async(conf2 => conf2.Debug(outputTemplate: LogFormat))
- .WriteTo.Async(conf3 =>
- conf3.File("logs/log-.txt", outputTemplate: LogFormat, rollingInterval: RollingInterval.Day));
+ .Enrich.With(new LoggerPropertyBagEnricher(LoggerPropertyBag));
+ configuration.WriteTo.Async(conf => conf.Console(outputTemplate: LogFormat));
+ configuration.WriteTo.Async(conf2 => conf2.Debug(outputTemplate: LogFormat));
+ configuration.WriteTo.Async(conf3 =>
+ conf3.File("logs/log-.txt", outputTemplate: LogFormat, rollingInterval: RollingInterval.Day));
return configuration;
}
- ///
- public void UseStderrForConsoleOutput() {
- _logger?.Dispose();
- _logger = null;
- _loggerConfiguration = new LoggerConfiguration()
- .Enrich.FromLogContext()
- .Enrich.With(new LoggerPropertyBagEnricher(LoggerPropertyBag))
- .WriteTo.Async(conf => conf.Console(outputTemplate: LogFormat, standardErrorFromLevel: Serilog.Events.LogEventLevel.Verbose))
- .WriteTo.Async(conf2 => conf2.Debug(outputTemplate: LogFormat))
- .WriteTo.Async(conf3 =>
- conf3.File("logs/log-.txt", outputTemplate: LogFormat, rollingInterval: RollingInterval.Day));
- _loggerConfiguration.MinimumLevel.ControlledBy(_logLevelSwitch);
- }
-
public void Write(LogEventLevel level, string messageTemplate) {
GetLoggerForLevel(level)?.Write(level, messageTemplate);
}
@@ -139,8 +121,6 @@ public void Dispose() {
private void ResetLogger() {
_logger?.Dispose();
_logger = null;
- _loggerConfiguration = CreateLoggerConfiguration();
- _loggerConfiguration.MinimumLevel.ControlledBy(_logLevelSwitch);
}
private Logger? GetLoggerForLevel(LogEventLevel level) {
@@ -148,10 +128,16 @@ private void ResetLogger() {
return null;
}
- _logger ??= _loggerConfiguration.CreateLogger();
+ _logger ??= BuildLogger();
return _logger;
}
+ private Logger BuildLogger() {
+ LoggerConfiguration configuration = CreateLoggerConfiguration();
+ configuration.MinimumLevel.ControlledBy(_logLevelSwitch);
+ return configuration.CreateLogger();
+ }
+
private static object?[] Normalize(object?[]? properties) {
return properties is { Length: > 0 } ? properties : EmptyProperties;
}
diff --git a/src/Spice86.Shared/Interfaces/ILoggerService.cs b/src/Spice86.Shared/Interfaces/ILoggerService.cs
index 1b2bc61094..aee7ff40a2 100644
--- a/src/Spice86.Shared/Interfaces/ILoggerService.cs
+++ b/src/Spice86.Shared/Interfaces/ILoggerService.cs
@@ -33,9 +33,4 @@ public interface ILoggerService : ILogger {
///
/// The new
LoggerConfiguration CreateLoggerConfiguration();
-
- ///
- /// Redirects console log output to stderr, freeing stdout for protocol transports (e.g., MCP stdio).
- ///
- void UseStderrForConsoleOutput();
}
diff --git a/src/Spice86/Spice86DependencyInjection.cs b/src/Spice86/Spice86DependencyInjection.cs
index 2ed6f944ce..594f27849d 100644
--- a/src/Spice86/Spice86DependencyInjection.cs
+++ b/src/Spice86/Spice86DependencyInjection.cs
@@ -726,24 +726,26 @@ internal Spice86DependencyInjection(Configuration configuration, MainWindow? mai
McpHttpHost? mcpHttpTransport = null;
- // Collect additional MCP tool assemblies and services from override supplier
- IEnumerable? additionalToolAssemblies = null;
- IEnumerable