Merge pull request #660 from Mbucari/master
Crash logging to chardonnay
This commit is contained in:
commit
1cf01aa92a
@ -67,13 +67,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
||||||
<PackageReference Include="Avalonia" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.0" />
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc2.2" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\HangoverBase\HangoverBase.csproj" />
|
<ProjectReference Include="..\HangoverBase\HangoverBase.csproj" />
|
||||||
|
|||||||
@ -70,13 +70,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-rc2.2" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
|
||||||
<PackageReference Include="Avalonia" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-rc2.2" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ApplicationServices;
|
using ApplicationServices;
|
||||||
using AppScaffolding;
|
using AppScaffolding;
|
||||||
@ -35,6 +34,7 @@ namespace LibationAvalonia
|
|||||||
$"\"{Configuration.ProcessDirectory}\"");
|
$"\"{Configuration.ProcessDirectory}\"");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += (o, e) => LogError(e.ExceptionObject);
|
||||||
|
|
||||||
//***********************************************//
|
//***********************************************//
|
||||||
// //
|
// //
|
||||||
@ -42,6 +42,8 @@ namespace LibationAvalonia
|
|||||||
// //
|
// //
|
||||||
//***********************************************//
|
//***********************************************//
|
||||||
// Migrations which must occur before configuration is loaded for the first time. Usually ones which alter the Configuration
|
// Migrations which must occur before configuration is loaded for the first time. Usually ones which alter the Configuration
|
||||||
|
try
|
||||||
|
{
|
||||||
var config = LibationScaffolding.RunPreConfigMigrations();
|
var config = LibationScaffolding.RunPreConfigMigrations();
|
||||||
|
|
||||||
//Start as much work in parallel as possible.
|
//Start as much work in parallel as possible.
|
||||||
@ -50,9 +52,11 @@ namespace LibationAvalonia
|
|||||||
|
|
||||||
if (config.LibationSettingsAreValid)
|
if (config.LibationSettingsAreValid)
|
||||||
{
|
{
|
||||||
if (!RunDbMigrations(config))
|
// most migrations go in here
|
||||||
return;
|
LibationScaffolding.RunPostConfigMigrations(config);
|
||||||
|
LibationScaffolding.RunPostMigrationScaffolding(Variety.Chardonnay, config);
|
||||||
|
|
||||||
|
//Start loading the library before loading the main form
|
||||||
App.LibraryTask = Task.Run(() => DbContexts.GetLibrary_Flat_NoTracking(includeParents: true));
|
App.LibraryTask = Task.Run(() => DbContexts.GetLibrary_Flat_NoTracking(includeParents: true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +64,11 @@ namespace LibationAvalonia
|
|||||||
|
|
||||||
classicLifetimeTask.Result.Start(null);
|
classicLifetimeTask.Result.Start(null);
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
LogError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static AppBuilder BuildAvaloniaApp()
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
=> AppBuilder.Configure<App>()
|
=> AppBuilder.Configure<App>()
|
||||||
@ -67,20 +76,35 @@ namespace LibationAvalonia
|
|||||||
.LogToTrace()
|
.LogToTrace()
|
||||||
.UseReactiveUI();
|
.UseReactiveUI();
|
||||||
|
|
||||||
public static bool RunDbMigrations(Configuration config)
|
private static void LogError(object exceptionObject)
|
||||||
|
{
|
||||||
|
var logError = $"""
|
||||||
|
{DateTime.Now} - Libation Crash
|
||||||
|
OS {Configuration.OS}
|
||||||
|
Version {LibationScaffolding.BuildVersion}
|
||||||
|
ReleaseIdentifier {LibationScaffolding.ReleaseIdentifier}
|
||||||
|
InteropFunctionsType {InteropFactory.InteropFunctionsType}
|
||||||
|
LibationFiles {getConfigValue(c => c.LibationFiles)}
|
||||||
|
Books Folder {getConfigValue(c => c.Books)}
|
||||||
|
=== EXCEPTION ===
|
||||||
|
{exceptionObject}
|
||||||
|
""";
|
||||||
|
|
||||||
|
var crashLog = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "LibationCrash.log");
|
||||||
|
|
||||||
|
using var sw = new StreamWriter(crashLog, true);
|
||||||
|
sw.WriteLine(logError);
|
||||||
|
|
||||||
|
static string getConfigValue(Func<Configuration, string> selector)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// most migrations go in here
|
return selector(Configuration.Instance);
|
||||||
LibationScaffolding.RunPostConfigMigrations(config);
|
|
||||||
LibationScaffolding.RunPostMigrationScaffolding(Variety.Chardonnay, config);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception exDebug)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Serilog.Log.Logger.Debug(exDebug, "Silent failure");
|
return ex.ToString();
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user