54 lines
1.6 KiB
C#
Raw Normal View History

2023-11-12 09:52:02 -05:00
using System.Linq;
using Avalonia;
2023-05-11 23:11:39 -04:00
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
2023-09-05 20:09:11 -04:00
using ReactiveUI;
using Serilog;
2023-05-11 23:11:39 -04:00
using SPTInstaller.ViewModels;
using SPTInstaller.Views;
2023-09-05 20:09:11 -04:00
using System.Reactive;
2023-05-11 23:11:39 -04:00
namespace SPTInstaller;
public partial class App : Application
2023-05-11 23:11:39 -04:00
{
public override void Initialize()
2023-05-11 23:11:39 -04:00
{
AvaloniaXamlLoader.Load(this);
2023-09-05 20:09:11 -04:00
2023-09-05 20:23:28 -04:00
var logPath = Path.Join(Environment.CurrentDirectory, "spt-aki-installer_.log");
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo
.File(path: logPath,
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug,
rollingInterval: RollingInterval.Day)
.CreateLogger();
2023-09-05 20:09:11 -04:00
RxApp.DefaultExceptionHandler = Observer.Create<Exception>((exception) =>
{
Log.Error(exception, "An application exception occurred");
});
}
2023-05-11 23:11:39 -04:00
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
2023-05-11 23:11:39 -04:00
{
2023-11-12 09:52:02 -05:00
if (desktop.Args != null && desktop.Args.Any(x => x.ToLower() == "debug"))
{
System.Diagnostics.Trace.Listeners.Add(new SerilogTraceListener.SerilogTraceListener());
Log.Debug("TraceListener is registered");
}
desktop.MainWindow = new MainWindow
2023-05-11 23:11:39 -04:00
{
DataContext = new MainWindowViewModel(),
};
2023-05-11 23:11:39 -04:00
}
base.OnFrameworkInitializationCompleted();
2023-05-11 23:11:39 -04:00
}
}