- Added Microsoft.Extensions.Logging to various projects for enhanced logging capabilities. - Updated AccessDbRepository and AttachmentRepository to include logging for database operations. - Integrated logging into MailListener for better error handling and operational insights. - Modified tests to utilize mocks for ILogger to ensure logging behavior is tested. - Enhanced App.xaml.cs and MainWindow.xaml.cs to log application startup and initialization events. - Created LoggingBootstrapper to configure logging services in the WPF application. - Updated TODOs-and-Roadmap.md to reflect the addition of logging features.
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System.Configuration;
|
|
using System.Data;
|
|
using System.Windows;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace ComplianceNFs.Monitor;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
public static ServiceProvider? ServiceProvider { get; private set; }
|
|
private ILogger<App>? _logger;
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
base.OnStartup(e);
|
|
// Setup DI and logging
|
|
ServiceProvider = LoggingBootstrapper.CreateServiceProvider();
|
|
_logger = ServiceProvider.GetRequiredService<ILogger<App>>();
|
|
_logger.LogInformation("App started");
|
|
this.DispatcherUnhandledException += (s, ex) =>
|
|
{
|
|
_logger?.LogError(ex.Exception, "Unhandled exception in WPF app");
|
|
};
|
|
// Optionally, resolve and show MainWindow with DI
|
|
var mainWindowLogger = ServiceProvider.GetRequiredService<ILogger<MainWindow>>();
|
|
var mainWindow = new MainWindow(mainWindowLogger);
|
|
mainWindow.Show();
|
|
}
|
|
}
|
|
|