ILog log = LogService.GetLogger();
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
string logFile = Path.Combine(logDir, string.Format("activity_log{0}.txt", GeneralUtilities.ProcessId));
+ if (!Directory.Exists(Path.GetDirectoryName(logFile)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(logFile));
+ }
+
log.Enable();
log.SetupLogHeader(GeneralUtilities.CreateLogHeader().ToString());
log.EnableLoggingToDisk(logFile, true);
/// </param>\r
private void Vm_LogMessageReceived(object sender, HandBrake.ApplicationServices.Services.Logging.EventArgs.LogEventArgs e)\r
{\r
- if (e == null)\r
+ try\r
{\r
- LogViewModel vm = this.DataContext as LogViewModel;\r
- if (vm != null)\r
+ if (e == null)\r
{\r
- this.logText.Clear();\r
- this.logText.AppendText(vm.ActivityLog);\r
+ Caliburn.Micro.Execute.OnUIThread(\r
+ () =>\r
+ {\r
+ LogViewModel vm = this.DataContext as LogViewModel;\r
+ if (vm != null)\r
+ {\r
+ this.logText.Clear();\r
+ this.logText.AppendText(vm.ActivityLog);\r
+ }\r
+ else\r
+ {\r
+ Debug.WriteLine("Failed to Reset Log correctly.");\r
+ }\r
+ }); \r
}\r
else\r
{\r
- Debug.WriteLine("Failed to Reset Log correctly.");\r
+ // This works better than Data Binding because of the scroll.\r
+ this.logText.AppendText(Environment.NewLine + e.Log.Content);\r
+\r
+ if (this.AutoScroll.IsChecked)\r
+ {\r
+ this.logText.ScrollToEnd();\r
+ }\r
}\r
}\r
- else\r
+ catch (Exception exc)\r
{\r
- // This works better than Data Binding because of the scroll.\r
- this.logText.AppendText(Environment.NewLine + e.Log.Content);\r
-\r
- if (this.AutoScroll.IsChecked)\r
- {\r
- this.logText.ScrollToEnd();\r
- }\r
+ Debug.WriteLine(exc);\r
}\r
}\r
\r