diff --git a/Hollow/Models/AppInfo.cs b/Hollow/Models/AppInfo.cs index e987f4c..375f1e2 100644 --- a/Hollow/Models/AppInfo.cs +++ b/Hollow/Models/AppInfo.cs @@ -9,7 +9,6 @@ public class AppInfo public static readonly string BasePath = Directory.GetCurrentDirectory(); public static readonly string ConfigPath = Path.Combine(BasePath, "config.json"); - public static readonly string CrushesDir = Path.Combine(BasePath, "crashes"); public static readonly string LogDir = Path.Combine(BasePath, "logs"); public static readonly string CachesDir = Path.Combine(BasePath, "caches"); public static readonly string GachaRecordsDir = Path.Combine(BasePath, "gacha_records"); diff --git a/Hollow/Program.cs b/Hollow/Program.cs index 77761f2..9532c50 100644 --- a/Hollow/Program.cs +++ b/Hollow/Program.cs @@ -19,14 +19,27 @@ public static void Main(string[] args) Log.Logger = new LoggerConfiguration() .Enrich.WithProperty("Version", AppInfo.AppVersion) .MinimumLevel.Debug() - .WriteTo.Console(outputTemplate: "[{Level}] {Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}") - .WriteTo.File(Path.Combine(AppInfo.LogDir, "log_.txt"), outputTemplate: "[{Level}] {Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, retainedFileCountLimit: null) + .WriteTo.Console(outputTemplate: "{Timestamp:HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}") + .WriteTo.File(Path.Combine(AppInfo.LogDir, "log_.txt"), outputTemplate: "{Timestamp:HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}", rollingInterval: RollingInterval.Day, retainedFileCountLimit: null) .CreateLogger(); + + Log.Information("Hollow is starting..."); //TODO: Platform specific Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", AppInfo.CachesDir); - BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + try + { + BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + } + catch (Exception e) + { + Log.Fatal(e, "Oops, Hollow crashed!"); + } + finally + { + Log.CloseAndFlush(); + } } // Avalonia configuration, don't remove; also used by visual designer. diff --git a/Hollow/Services/ConfigurationService/ConfigurationService.cs b/Hollow/Services/ConfigurationService/ConfigurationService.cs index c6e3242..61d1b32 100644 --- a/Hollow/Services/ConfigurationService/ConfigurationService.cs +++ b/Hollow/Services/ConfigurationService/ConfigurationService.cs @@ -23,7 +23,6 @@ public ConfigurationService() public static AppConfig LoadConfiguration() { Directory.CreateDirectory(AppInfo.BasePath); - Directory.CreateDirectory(AppInfo.CrushesDir); Directory.CreateDirectory(AppInfo.LogDir); Directory.CreateDirectory(AppInfo.CachesDir); Directory.CreateDirectory(AppInfo.GachaRecordsDir); diff --git a/Hollow/ViewModels/Pages/AnnouncementsViewModel.cs b/Hollow/ViewModels/Pages/AnnouncementsViewModel.cs index 3cb7bd4..6b6ba7b 100644 --- a/Hollow/ViewModels/Pages/AnnouncementsViewModel.cs +++ b/Hollow/ViewModels/Pages/AnnouncementsViewModel.cs @@ -72,7 +72,7 @@ public void GameAnnouncementWebView_OnWebViewCreated(object? sender, WebViewCrea AnnouncementLoadingCoverageOpacity = 1; AnnouncementLoaded = false; //TODO: Platform specific - if (Announcements.AnnouncementWebView.PlatformWebView is WebView2Core webView2Core) + if (Announcements.AnnouncementWebView.PlatformWebView is WebView2Core { CoreWebView2: not null } webView2Core) { webView2Core.CoreWebView2!.DOMContentLoaded += async (_, _) => { diff --git a/Hollow/ViewModels/Pages/HomeViewModel.cs b/Hollow/ViewModels/Pages/HomeViewModel.cs index 947813d..f5552f4 100644 --- a/Hollow/ViewModels/Pages/HomeViewModel.cs +++ b/Hollow/ViewModels/Pages/HomeViewModel.cs @@ -39,8 +39,6 @@ public HomeViewModel(IMiHoYoLauncherService miHoYoLauncherService, HttpClient ht _httpClient = httpClient; _configurationService = configurationService; _gameService = gameService; - - Log.Information("test"); _ = LoadContents(); CheckStartGameReady(); diff --git a/Hollow/Views/MainWindow.axaml.cs b/Hollow/Views/MainWindow.axaml.cs index fb5733c..c5cadbb 100644 --- a/Hollow/Views/MainWindow.axaml.cs +++ b/Hollow/Views/MainWindow.axaml.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; +using Serilog; namespace Hollow.Views; @@ -19,6 +20,7 @@ private void MinimizeButton_OnClick(object? _1, RoutedEventArgs _2) private void CloseButton_OnClick(object? _1, RoutedEventArgs _2) { + Log.CloseAndFlush(); Environment.Exit(0); }