mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 11:14:45 +00:00
Use Serilog in EntityFramework Core logging.
This commit is contained in:
@@ -33,6 +33,8 @@ using RomRepoMgr.Core.Models;
|
||||
using RomRepoMgr.Database;
|
||||
using RomRepoMgr.Database.Models;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -207,7 +209,8 @@ public partial class EditDatViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCommandAsync()
|
||||
{
|
||||
await using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
await using var ctx =
|
||||
Context.Create(Settings.Settings.Current.DatabasePath, new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
RomSet romSetDb = await ctx.RomSets.FindAsync(_romSet.Id);
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using RomRepoMgr.Core.EventArgs;
|
||||
using RomRepoMgr.Core.Workers;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -154,7 +156,7 @@ public sealed partial class ExportRomsViewModel : ViewModelBase
|
||||
|
||||
public void OnOpened()
|
||||
{
|
||||
var worker = new FileExporter(_romSetId, FolderPath);
|
||||
var worker = new FileExporter(_romSetId, FolderPath, new SerilogLoggerFactory(Log.Logger));
|
||||
worker.SetMessage += OnWorkerOnSetMessage;
|
||||
worker.SetProgress += OnWorkerOnSetProgress;
|
||||
worker.SetProgressBounds += OnWorkerOnSetProgressBounds;
|
||||
|
||||
@@ -14,6 +14,8 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using RomRepoMgr.Core.EventArgs;
|
||||
using RomRepoMgr.Models;
|
||||
using RomRepoMgr.Resources;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -134,7 +136,9 @@ public sealed partial class ImportDatFolderViewModel : ViewModelBase
|
||||
Indeterminate = false
|
||||
};
|
||||
|
||||
var worker = new Core.Workers.DatImporter(_datFiles[_listPosition], Category);
|
||||
var worker =
|
||||
new Core.Workers.DatImporter(_datFiles[_listPosition], Category, new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
worker.ErrorOccurred += model.OnErrorOccurred;
|
||||
worker.SetIndeterminateProgress += model.OnSetIndeterminateProgress;
|
||||
worker.SetMessage += model.OnSetMessage;
|
||||
|
||||
@@ -32,6 +32,8 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using RomRepoMgr.Core.EventArgs;
|
||||
using RomRepoMgr.Core.Workers;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -68,7 +70,7 @@ public sealed partial class ImportDatViewModel : ViewModelBase
|
||||
IndeterminateProgress = true;
|
||||
ProgressVisible = false;
|
||||
ErrorVisible = false;
|
||||
_worker = new DatImporter(datPath, null);
|
||||
_worker = new DatImporter(datPath, null, new SerilogLoggerFactory(Log.Logger));
|
||||
_worker.ErrorOccurred += OnWorkerOnErrorOccurred;
|
||||
_worker.SetIndeterminateProgress += OnWorkerOnSetIndeterminateProgress;
|
||||
_worker.SetMessage += OnWorkerOnSetMessage;
|
||||
|
||||
@@ -19,12 +19,14 @@ using RomRepoMgr.Database.Models;
|
||||
using RomRepoMgr.Models;
|
||||
using RomRepoMgr.Resources;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
public sealed partial class ImportRomFolderViewModel : ViewModelBase
|
||||
{
|
||||
readonly Context _ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
readonly Context _ctx =
|
||||
Context.Create(Settings.Settings.Current.DatabasePath, new SerilogLoggerFactory(Log.Logger));
|
||||
readonly ConcurrentBag<DbDisk> _newDisks = [];
|
||||
readonly ConcurrentBag<DbFile> _newFiles = [];
|
||||
readonly ConcurrentBag<DbMedia> _newMedias = [];
|
||||
|
||||
@@ -45,6 +45,7 @@ using RomRepoMgr.Core.Models;
|
||||
using RomRepoMgr.Resources;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -267,7 +268,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
|
||||
|
||||
try
|
||||
{
|
||||
Vfs = new Vfs();
|
||||
Vfs = new Vfs(new SerilogLoggerFactory(Log.Logger));
|
||||
Vfs.Umounted += VfsOnUmounted;
|
||||
Vfs.MountTo(result[0].Path.LocalPath);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ using RomRepoMgr.Database;
|
||||
using RomRepoMgr.Database.Models;
|
||||
using RomRepoMgr.Resources;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -55,7 +57,8 @@ public sealed partial class RemoveDatViewModel : ViewModelBase
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
|
||||
new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
Dispatcher.UIThread.Post(() => StatusMessage = Localization.RetrievingRomSetFromDatabase);
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ using RomRepoMgr.Core.Workers;
|
||||
using RomRepoMgr.Database;
|
||||
using RomRepoMgr.Resources;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
using ErrorEventArgs = RomRepoMgr.Core.EventArgs.ErrorEventArgs;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
@@ -227,7 +229,7 @@ public sealed partial class SettingsViewModel : ViewModelBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var ctx = Context.Create(result);
|
||||
var ctx = Context.Create(result, new SerilogLoggerFactory(Log.Logger));
|
||||
await ctx.Database.MigrateAsync();
|
||||
}
|
||||
catch
|
||||
@@ -295,7 +297,7 @@ public sealed partial class SettingsViewModel : ViewModelBase
|
||||
|
||||
try
|
||||
{
|
||||
var ctx = Context.Create(result);
|
||||
var ctx = Context.Create(result, new SerilogLoggerFactory(Log.Logger));
|
||||
await ctx.Database.MigrateAsync();
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -39,6 +39,7 @@ using RomRepoMgr.Core.Models;
|
||||
using RomRepoMgr.Core.Workers;
|
||||
using RomRepoMgr.Database;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -175,7 +176,8 @@ public sealed partial class SplashWindowViewModel : ViewModelBase
|
||||
|
||||
if(!Directory.Exists(dbPathFolder)) Directory.CreateDirectory(dbPathFolder);
|
||||
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
|
||||
new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
Dispatcher.UIThread.Post(MigrateDatabase);
|
||||
}
|
||||
@@ -203,7 +205,8 @@ public sealed partial class SplashWindowViewModel : ViewModelBase
|
||||
{
|
||||
try
|
||||
{
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
|
||||
new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
ctx.Database.Migrate();
|
||||
|
||||
@@ -233,7 +236,8 @@ public sealed partial class SplashWindowViewModel : ViewModelBase
|
||||
{
|
||||
try
|
||||
{
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
|
||||
new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
GotRomSets?.Invoke(this,
|
||||
new RomSetsEventArgs
|
||||
|
||||
@@ -36,6 +36,8 @@ using RomRepoMgr.Database;
|
||||
using RomRepoMgr.Database.Models;
|
||||
using RomRepoMgr.Resources;
|
||||
using RomRepoMgr.Views;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace RomRepoMgr.ViewModels;
|
||||
|
||||
@@ -79,7 +81,8 @@ public sealed partial class UpdateStatsViewModel : ViewModelBase
|
||||
{
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
|
||||
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
|
||||
new SerilogLoggerFactory(Log.Logger));
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user