mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
General - Log fatal exceptions on all platforms
This commit is contained in:
parent
b875e3d366
commit
021f17aef4
@ -17,6 +17,7 @@ namespace Artemis.UI.Linux
|
||||
public override void Initialize()
|
||||
{
|
||||
_kernel = ArtemisBootstrapper.Bootstrap(this);
|
||||
Program.CreateLogger(_kernel);
|
||||
RxApp.MainThreadScheduler = AvaloniaScheduler.Instance;
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Ninject;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.UI.Linux
|
||||
{
|
||||
@ -12,7 +14,15 @@ namespace Artemis.UI.Linux
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
try
|
||||
{
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger?.Fatal(e, "Fatal exception, shutting down");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
@ -20,5 +30,12 @@ namespace Artemis.UI.Linux
|
||||
{
|
||||
return AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace().UseReactiveUI();
|
||||
}
|
||||
|
||||
private static ILogger? Logger { get; set; }
|
||||
|
||||
public static void CreateLogger(IKernel kernel)
|
||||
{
|
||||
Logger = kernel.Get<ILogger>().ForContext<Program>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,19 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using Ninject;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.MacOS
|
||||
{
|
||||
public class App : Application
|
||||
{
|
||||
private StandardKernel? _kernel;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
ArtemisBootstrapper.Bootstrap(this);
|
||||
_kernel = ArtemisBootstrapper.Bootstrap(this);
|
||||
Program.CreateLogger(_kernel);
|
||||
RxApp.MainThreadScheduler = AvaloniaScheduler.Instance;
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Ninject;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.UI.MacOS
|
||||
{
|
||||
@ -12,7 +14,15 @@ namespace Artemis.UI.MacOS
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
try
|
||||
{
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger?.Fatal(e, "Fatal exception, shutting down");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Avalonia configuration, don't remove; also used by visual designer.
|
||||
@ -20,5 +30,12 @@ namespace Artemis.UI.MacOS
|
||||
{
|
||||
return AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace().UseReactiveUI();
|
||||
}
|
||||
|
||||
private static ILogger? Logger { get; set; }
|
||||
|
||||
public static void CreateLogger(IKernel kernel)
|
||||
{
|
||||
Logger = kernel.Get<ILogger>().ForContext<Program>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -37,9 +37,9 @@ namespace Artemis.UI.Windows
|
||||
inputService.AddInputProvider(standardKernel.Get<WindowsInputProvider>());
|
||||
}
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
private StandardKernel? _kernel;
|
||||
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
private ApplicationStateManager? _applicationStateManager;
|
||||
// ReSharper restore NotAccessedField.Local
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user