Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
febbe6c
Initial plan
Copilot Feb 6, 2026
b9505b5
Work in Progress on Logging Refactor. (#178)
michaelbeale-IL Feb 7, 2026
5ebdff5
Convert BCIActuator.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
540325b
Fix exception logging and spelling errors in BCIActuator.cs
Copilot Feb 7, 2026
bdb2b93
Fix empty LogTrace call and spelling error in BCIActuator.cs
Copilot Feb 7, 2026
ee30858
Adjust log severity levels based on code review
Copilot Feb 7, 2026
ce0ec44
Remove redundant exception messages from LogError calls
Copilot Feb 7, 2026
5d4d9eb
Improve exception log messages and fix formatting
Copilot Feb 7, 2026
27852cc
Replace redundant exception messages with contextual descriptions
Copilot Feb 7, 2026
c40c38b
Use structured logging and fix commented code
Copilot Feb 7, 2026
219de64
Convert AnimationPlayer.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
f48a5c2
Convert AgentManager to Microsoft.Extensions.Logging
Copilot Feb 7, 2026
27eac78
Improve LogTrace calls with descriptive messages
Copilot Feb 7, 2026
b88bc28
Convert PanelStack.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
f5372e2
Convert DAQ_OpenBCI.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
b0c3e9b
Convert TextUtils.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
c982e85
Convert ScannerCommon.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
ff8f6d3
Convert ActuatorManager.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
49b0321
Convert DAQ_gTecBCI.cs to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
38e0a41
Convert UserControlBCISignalCheck to use Microsoft.Extensions.Logging
Copilot Feb 7, 2026
a9ea04f
Merge branch 'master' into copilot/migrate-log-debug-to-logger
michaelbeale-IL Feb 8, 2026
6b72916
Removed unecessary verbose log messages.
michaelbeale-IL Feb 8, 2026
889e565
Convert Log.* calls to ILogger pattern in 9 files
Copilot Feb 8, 2026
e673fa0
Fix redundant exception logging in PreferredAgents and DimReductChanSel
Copilot Feb 8, 2026
68e4141
Fix redundant exception message and mark logger as NonSerialized
Copilot Feb 8, 2026
d2bdc5a
Remove redundant initialization log message in PreferredAgents
Copilot Feb 8, 2026
3825c24
Add null check for logger in DimReductChanSel after deserialization
Copilot Feb 8, 2026
0865d3f
Convert Log.* calls to ILogger in 10 ACATCore files
Copilot Feb 8, 2026
943abf3
Convert Log.* calls to ILogger pattern in 10 ACATCore files
Copilot Feb 8, 2026
c2b75e9
Use LoggingConfiguration.CreateLogger for static loggers in ProfileMa…
Copilot Feb 8, 2026
c34e038
Improve error message clarity in LayoutAttribute widget instantiation
Copilot Feb 8, 2026
8634341
Convert Log.* calls to ILogger pattern in 6 files
Copilot Feb 8, 2026
1071b0b
Convert Log.* calls to ILogger pattern in 10 files
Copilot Feb 8, 2026
f6e989f
Convert Log.* calls to ILogger pattern in 10 files
Copilot Feb 8, 2026
756947f
Convert Log.* calls to ILogger pattern in 10 files
Copilot Feb 8, 2026
1c7b6e7
Convert Log.* calls to ILogger pattern in 10 files
Copilot Feb 8, 2026
538dea7
Convert Log.* calls to ILogger pattern in 6 files (94 calls total)
Copilot Feb 8, 2026
7668faf
Convert Log.* calls to ILogger pattern in TextControlAgentBase
Copilot Feb 8, 2026
ea18605
Convert TalkApplicationBCIScanner to ILogger pattern
Copilot Feb 8, 2026
a7ea383
Convert FeatureExtraction.cs to ILogger pattern
Copilot Feb 8, 2026
45ae3ea
Convert Log calls to ILogger in TextController.cs
Copilot Feb 8, 2026
61f0b08
Fix spelling in parameter name and improve LogTrace message
Copilot Feb 8, 2026
6a9fcff
Fix double space in log message template
Copilot Feb 8, 2026
174ef17
Convert CameraActuator logging to ILogger
Copilot Feb 8, 2026
5adec61
Convert PanelAnimationManager to use ILogger with structured logging
Copilot Feb 8, 2026
d685829
Convert logging in OpenBCIDeviceTester.cs to Microsoft.Extensions.Log…
Copilot Feb 8, 2026
0c35d36
Convert Log.Debug to _logger.LogDebug in SensorForm.cs
Copilot Feb 8, 2026
e8f0e23
Convert all 26 Log calls to ILogger in DecisionMaker.cs
Copilot Feb 8, 2026
22b93cc
Use NullLogger singleton for efficient default logger
Copilot Feb 8, 2026
94c08ce
Rename _defaultLogger to _nullLogger for clarity
Copilot Feb 8, 2026
c780c15
Convert 26 Log calls to ILogger in UserControlAnimationManager
Copilot Feb 8, 2026
ee88539
Standardize logger creation with LoggingConfiguration
michaelbeale-IL Feb 9, 2026
eba1980
Refactor logger usage and cleanup in handler/util classes
michaelbeale-IL Feb 9, 2026
0d2ae1e
Refactor logging and naming for consistency and robustness
michaelbeale-IL Feb 9, 2026
bcae10a
Refactor: Add DI & centralized logging for managers/extensions
michaelbeale-IL Feb 10, 2026
55c8941
Refactor: Migrate logging from Log to ILogger for improved consistency
michaelbeale-IL Feb 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/Applications/ACATApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
using ACAT.Extension;
using ACAT.Extension.CommandHandlers;
using ACATResources;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Windows.Forms;
using System.Windows.Navigation;

namespace ACATApp
{
Expand All @@ -36,8 +36,9 @@ namespace ACATApp
internal static class Program
{
private static Splash splash = null;
private static Microsoft.Extensions.Logging.ILoggerFactory modernLoggingFactory = null;
private static ILoggerFactory modernLoggingFactory = null;
private static ILogger _logger;
private static IServiceProvider _serviceProvider;

/// <summary>
/// The main entry point for the application.
Expand All @@ -56,6 +57,7 @@ public static void Main(string[] args)
InitializeGlobals();
InitializeUser();
InitializeLogging();
InitializeDependencyInjection();
InitializeContext();

if (!PerformOnboarding())
Expand Down Expand Up @@ -101,14 +103,31 @@ private static void InitializeLogging()
{
// Initialize legacy logging
Log.SetupListeners();
// Initialize modern logging infrastructure (ticket #3)

// Initialize modern logging infrastructure
modernLoggingFactory = LoggingConfiguration.CreateLoggerFactory();
_logger = modernLoggingFactory.CreateLogger(typeof(Program));

_logger.LogDebug("ACAT Dashboard Application Launch");
}

private static void InitializeDependencyInjection()
{
// Set up dependency injection for extension instantiation
var services = new ServiceCollection();

// Add logging (reuse existing factory)
services.AddSingleton<ILoggerFactory>(modernLoggingFactory);
services.AddLogging();

_serviceProvider = services.BuildServiceProvider();

// Make service provider available to Context for extension loading
Context.ServiceProvider = _serviceProvider;

_logger.LogDebug("Dependency injection initialized");
}

private static void InitializeUser()
{
AppCommon.SetUserName();
Expand Down Expand Up @@ -213,7 +232,7 @@ private static void ShutdownApplication()
Context.Dispose();
Common.Uninit();
CloseSplashScreen();
_logger.LogDebug("ACATTalk Application shutdown");
_logger.LogDebug("ACAT Dashboard Application shutdown");
Log.Close();
modernLoggingFactory?.Dispose();
AppCommon.OnExit();
Expand Down
18 changes: 13 additions & 5 deletions src/Applications/ACATConfigNext/Forms/SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using ACAT.Core.WidgetManagement;
using ACAT.Extension;
using ACATConfigNext.UserControls;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
Expand All @@ -20,6 +21,7 @@ namespace ACATConfigNext.Forms
public class SettingsForm : Form
{
private readonly ILogger<SettingsForm> _logger;
private readonly IServiceProvider _serviceProvider;
private TableLayoutPanel basePanel;
private FlowLayoutPanel leftPanel;
private TableLayoutPanel navPanel;
Expand All @@ -42,13 +44,13 @@ public class SettingsForm : Form

private bool _isDirty = false;

public SettingsForm(ILogger<SettingsForm> logger)
public SettingsForm(ILogger<SettingsForm> logger, IServiceProvider serviceProvider)
{
_logger = logger;
_serviceProvider = serviceProvider;
WpfInitializationHelper.EnsureApplicationResources();

InitializeComponent();

}

private FlowLayoutPanel CreateLeftPanel()
Expand Down Expand Up @@ -159,7 +161,7 @@ private void ButtonClicked_Save(object sender, EventArgs e)
}
catch (Exception ex)
{
Log.Exception(ex);
_logger.LogError(ex, "Error occurred while saving settings");
MessageBox.Show("An error occurred while saving settings.", "Save Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Expand Down Expand Up @@ -410,6 +412,12 @@ private void CopyPreferencesValues(IPreferences source, IPreferences target)
}
}

private object CreateExtensionInstance(Type type)
{
// Use shared helper method for consistent extension instantiation across all applications
return ExtensionHelper.CreateExtensionInstance(_serviceProvider, type, _logger);
}


private IEnumerable<IExtension> LoadSettings(string category)
{
Expand All @@ -431,7 +439,7 @@ private IEnumerable<IExtension> LoadSettings(string category)
{
var wordPredictorTypes = Context.AppWordPredictionManager.WordPredictorExtensions;
var wordPredictorExtensions = wordPredictorTypes
.Select(type => Activator.CreateInstance(type) as IExtension)
.Select(type => CreateExtensionInstance(type) as IExtension)
.Where(instance => instance != null);
return wordPredictorExtensions;

Expand All @@ -443,7 +451,7 @@ private IEnumerable<IExtension> LoadSettings(string category)
{
var ttsEngineTypes = Context.AppTTSManager.GetExtensions();
var ttsExtensions = ttsEngineTypes
.Select(type => Activator.CreateInstance(type) as IExtension)
.Select(type => CreateExtensionInstance(type) as IExtension)
.Where(instance => instance != null);
return ttsExtensions;
}
Expand Down
24 changes: 23 additions & 1 deletion src/Applications/ACATConfigNext/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using ACATConfigNext.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Windows.Forms;

Expand All @@ -15,7 +17,27 @@ static void Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new SettingsForm());
// Set up dependency injection
var services = new ServiceCollection();
ConfigureServices(services);
var serviceProvider = services.BuildServiceProvider();

// Get SettingsForm from DI container
var settingsForm = serviceProvider.GetRequiredService<SettingsForm>();
Application.Run(settingsForm);
}

private static void ConfigureServices(IServiceCollection services)
{
// Configure logging
services.AddLogging(builder =>
{
builder.AddConsole();
builder.SetMinimumLevel(LogLevel.Information);
});

// Register SettingsForm - IServiceProvider will be injected automatically
services.AddTransient<SettingsForm>();
}
}
}
38 changes: 27 additions & 11 deletions src/Applications/ACATTalk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using ACAT.Extension;
using ACAT.Extension.CommandHandlers;
using ACATResources;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Windows.Forms;
Expand All @@ -34,7 +35,9 @@ namespace ACATTalk
internal static class Program
{
private static Splash splash = null;
private static ILoggerFactory modernLoggingFactory = null;
private static ILogger _logger;
private static IServiceProvider _serviceProvider;

/// <summary>
/// The main entry point for the application.
Expand All @@ -50,11 +53,6 @@ public static void Main(string[] args)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

//if (!AppCommon.CheckFontsInstalled())
//{
// return;
//}

CoreGlobals.AppId = "ACATTalk";
CoreGlobals.ACATUserGuideFileName = "ACAT User Guide.pdf";
FatalErrorHandler.EvtFatalError += CoreGlobals_EvtFatalError;
Expand All @@ -66,8 +64,6 @@ public static void Main(string[] args)
AppCommon.SetUserName();
AppCommon.SetProfileName();

bool freshInstallForUser = !UserManager.UserExists(UserManager.CurrentUser);

if (!AppCommon.CreateUserAndProfile())
{
return;
Expand All @@ -91,12 +87,17 @@ public static void Main(string[] args)
// Initialize legacy logging system
Log.SetupListeners();

// Initialize modern logging infrastructure (ticket #3)
var modernLoggingFactory = LoggingConfiguration.CreateLoggerFactory();
// Initialize modern logging infrastructure FIRST - before anything else needs it
modernLoggingFactory = LoggingConfiguration.CreateLoggerFactory();
LogManager.Initialize(modernLoggingFactory); // Initialize global logger manager

_logger = modernLoggingFactory.CreateLogger(typeof(Program));

_logger.LogDebug("ACAT Talk Application Launch");

// Set up dependency injection for extension instantiation
InitializeDependencyInjection();

AuditLog.Audit(new AuditEvent("Application", "start"));

CommandDescriptors.Init();
Expand Down Expand Up @@ -193,7 +194,6 @@ public static void Main(string[] args)

Common.Uninit();


splash?.Close();
splash = null;

Expand All @@ -211,6 +211,23 @@ public static void Main(string[] args)
AppCommon.OnExit();
}

private static void InitializeDependencyInjection()
{
// Set up dependency injection for extension instantiation
var services = new ServiceCollection();

// Add logging (reuse existing factory)
services.AddSingleton<ILoggerFactory>(modernLoggingFactory);
services.AddLogging();

_serviceProvider = services.BuildServiceProvider();

// Make service provider available to Context for extension loading
Context.ServiceProvider = _serviceProvider;

_logger.LogDebug("Dependency injection initialized");
}

/// <summary>
/// A fatal error has occurred. Try and gracefully exit ACAT
/// </summary>
Expand All @@ -219,7 +236,6 @@ private static void CoreGlobals_EvtFatalError(string reason)
{
splash?.Close();


if (Context.AppPanelManager != null && Context.AppPanelManager.GetCurrentForm() != null &&
Context.AppPanelManager.GetCurrentForm().PanelCommon != null && Context.AppPanelManager.GetCurrentForm().PanelCommon.RootWidget != null)
{
Expand Down
46 changes: 46 additions & 0 deletions src/Applications/AppCommon/ExtensionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using ACAT.Core.Extensions;
using ACAT.Core.Utility;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;

namespace ACAT.Applications
{
/// <summary>
/// Helper class for creating extension instances with proper dependency injection
/// Wrapper around ExtensionInstantiator from ACAT.Core for backward compatibility
/// </summary>
public static class ExtensionHelper
{
/// <summary>
/// Creates instances of extension types using dependency injection.
/// This ensures extensions receive proper logger instances and other registered services.
/// </summary>
/// <param name="serviceProvider">The service provider for dependency resolution</param>
/// <param name="extensionTypes">Collection of extension types to instantiate</param>
/// <param name="logger">Optional logger for diagnostics</param>
/// <returns>Collection of successfully created extension instances</returns>
public static IEnumerable<IExtension> CreateExtensionInstances(
IServiceProvider serviceProvider,
IEnumerable<Type> extensionTypes,
ILogger logger = null)
{
return ExtensionInstantiator.CreateExtensionInstances(serviceProvider, extensionTypes, logger);
}

/// <summary>
/// Creates a single extension instance using dependency injection
/// </summary>
/// <param name="serviceProvider">The service provider for dependency resolution</param>
/// <param name="extensionType">The extension type to instantiate</param>
/// <param name="logger">Optional logger for diagnostics</param>
/// <returns>The created extension instance, or null if creation fails</returns>
public static IExtension CreateExtensionInstance(
IServiceProvider serviceProvider,
Type extensionType,
ILogger logger = null)
{
return ExtensionInstantiator.CreateExtensionInstance(serviceProvider, extensionType, logger) as IExtension;
}
}
}
4 changes: 2 additions & 2 deletions src/Applications/AppCommon/Onboarding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static bool DoOnboarding()

public static bool ResetAllPreferences(List<PreferencesCategory> currentCategory)
{
var logger = LoggingConfiguration.CreateLogger(typeof(AppCommon));
var logger = LoggingConfiguration.CreateLogger<AppCommon>();
try
{
// Reset general preferences
Expand Down Expand Up @@ -91,7 +91,7 @@ public static bool ResetAllPreferences(List<PreferencesCategory> currentCategory

private static void CopyPreferencesValues(IPreferences source, IPreferences target)
{
var logger = LoggingConfiguration.CreateLogger(typeof(AppCommon));
var logger = LoggingConfiguration.CreateLogger<AppCommon>();
var sourceType = source.GetType();
var targetType = target.GetType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using ACAT.Extensions.Onboarding.UI.UserControls;
using ACAT.Extensions.Onboarding.UI;
using ACAT.Core.CoreInterfaces;
using Microsoft.Extensions.Logging;
using System.Globalization;

namespace ACAT.Extensions.Onboarding.Onboarding
Expand All @@ -25,8 +26,14 @@ public class OnboardingLanguageSelect : OnboardingExtensionBase
// TODO - Localize Me
private const string Step1 = "STEP 1";

private readonly ILogger<OnboardingLanguageSelect> _logger;
private IOnboardingWizard _wizard;

public OnboardingLanguageSelect()
{
_logger = LoggingConfiguration.CreateLogger<OnboardingLanguageSelect>();
}

public override ClassDescriptorAttribute Descriptor
{
get { return ClassDescriptorAttribute.GetDescriptor(GetType()); }
Expand Down Expand Up @@ -85,7 +92,7 @@ public override void OnEndStep(IOnboardingUserControl userControl, Reason reason
{
case Step1:
var cultureInfo = userControlLang.currentCulture;
Log.Debug ("User selected language: " + cultureInfo.DisplayName);
_logger.LogDebug("User selected language: {LanguageName}", cultureInfo.DisplayName);

CoreGlobals.AppPreferences.Language = cultureInfo.TwoLetterISOLanguageName;
CoreGlobals.AppPreferences.Save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private void UserControlHardwareSwitchSetup_Load(object sender, EventArgs e)
}

String html = String.Format(_htmlTemplate, headStyle, bodyStyle, textStyle, "Click <a href=" + HtmlUtils.EncodeString(CoreGlobals.ACATUserGuideFileName) + "#" + bookmark + ">here</a> for help");
Log.Debug(html);
_logger.LogDebug("Generated HTML: {Html}", html);

webBrowser.DocumentText = html;
//webBrowser.DocumentText =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void WebBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs
{
var str = e.Url.ToString();

Log.Debug("Url is [" + str + "]");
_logger.LogDebug("Url is [{Url}]", str);

if (str.ToLower().Contains("blank"))
{
Expand Down
Loading