|
25 | 25 | using Files.CommandLine;
|
26 | 26 | using Files.View_Models;
|
27 | 27 | using Files.Controls;
|
| 28 | +using NLog; |
28 | 29 |
|
29 | 30 | namespace Files
|
30 | 31 | {
|
@@ -56,23 +57,40 @@ public static IShellPage CurrentInstance
|
56 | 57 | public static ObservableCollection<WSLDistroItem> linuxDistroItems = new ObservableCollection<WSLDistroItem>();
|
57 | 58 | public static SettingsViewModel AppSettings { get; set; }
|
58 | 59 |
|
| 60 | + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); |
| 61 | + |
59 | 62 | public App()
|
60 | 63 | {
|
61 | 64 | this.InitializeComponent();
|
62 | 65 | this.Suspending += OnSuspending;
|
| 66 | + |
| 67 | + // Initialize NLog |
| 68 | + Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; |
| 69 | + NLog.LogManager.Configuration.Variables["LogPath"] = storageFolder.Path; |
| 70 | + |
| 71 | + RegisterUncaughtExceptionLogger(); |
| 72 | + |
63 | 73 | consentDialog = new Dialogs.ConsentDialog();
|
64 | 74 | propertiesDialog = new Dialogs.PropertiesDialog();
|
65 | 75 | layoutDialog = new Dialogs.LayoutDialog();
|
66 | 76 | addItemDialog = new Dialogs.AddItemDialog();
|
67 | 77 | exceptionDialog = new Dialogs.ExceptionDialog();
|
68 |
| - //this.UnhandledException += App_UnhandledException; |
| 78 | + // this.UnhandledException += App_UnhandledException; |
69 | 79 | Clipboard.ContentChanged += Clipboard_ContentChanged;
|
70 | 80 | Clipboard_ContentChanged(null, null);
|
71 | 81 | AppCenter.Start("682666d1-51d3-4e4a-93d0-d028d43baaa0", typeof(Analytics), typeof(Crashes));
|
72 | 82 |
|
73 | 83 | AppSettings = new SettingsViewModel();
|
74 | 84 | }
|
75 | 85 |
|
| 86 | + private void RegisterUncaughtExceptionLogger() |
| 87 | + { |
| 88 | + UnhandledException += (sender, args) => |
| 89 | + { |
| 90 | + Logger.Error(args.Exception, args.Message); |
| 91 | + }; |
| 92 | + } |
| 93 | + |
76 | 94 | private void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs args)
|
77 | 95 | {
|
78 | 96 | if (args.CurrentPoint.Properties.IsXButton1Pressed)
|
@@ -172,7 +190,9 @@ public static IReadOnlyList<ContentDialog> FindDisplayedContentDialogs<T>()
|
172 | 190 | /// <param name="e">Details about the launch request and process.</param>
|
173 | 191 | protected override void OnLaunched(LaunchActivatedEventArgs e)
|
174 | 192 | {
|
175 |
| - bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch"); |
| 193 | + Logger.Info("App launched"); |
| 194 | + |
| 195 | + bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch"); |
176 | 196 |
|
177 | 197 | Frame rootFrame = Window.Current.Content as Frame;
|
178 | 198 |
|
@@ -220,6 +240,8 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
|
220 | 240 |
|
221 | 241 | protected override void OnActivated(IActivatedEventArgs args)
|
222 | 242 | {
|
| 243 | + Logger.Info("App activated"); |
| 244 | + |
223 | 245 | // Window management
|
224 | 246 | Frame rootFrame = Window.Current.Content as Frame;
|
225 | 247 | if (rootFrame == null)
|
|
0 commit comments