diff options
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrakeWPF/Helpers/LogManager.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/LogView.xaml.cs | 39 |
2 files changed, 30 insertions, 14 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/LogManager.cs b/win/CS/HandBrakeWPF/Helpers/LogManager.cs index 4e883f8ee..70347fca1 100644 --- a/win/CS/HandBrakeWPF/Helpers/LogManager.cs +++ b/win/CS/HandBrakeWPF/Helpers/LogManager.cs @@ -31,6 +31,11 @@ namespace HandBrakeWPF.Helpers 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); diff --git a/win/CS/HandBrakeWPF/Views/LogView.xaml.cs b/win/CS/HandBrakeWPF/Views/LogView.xaml.cs index 2ab427752..67d2f21df 100644 --- a/win/CS/HandBrakeWPF/Views/LogView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/LogView.xaml.cs @@ -60,28 +60,39 @@ namespace HandBrakeWPF.Views /// </param>
private void Vm_LogMessageReceived(object sender, HandBrake.ApplicationServices.Services.Logging.EventArgs.LogEventArgs e)
{
- if (e == null)
+ try
{
- LogViewModel vm = this.DataContext as LogViewModel;
- if (vm != null)
+ if (e == null)
{
- this.logText.Clear();
- this.logText.AppendText(vm.ActivityLog);
+ Caliburn.Micro.Execute.OnUIThread(
+ () =>
+ {
+ LogViewModel vm = this.DataContext as LogViewModel;
+ if (vm != null)
+ {
+ this.logText.Clear();
+ this.logText.AppendText(vm.ActivityLog);
+ }
+ else
+ {
+ Debug.WriteLine("Failed to Reset Log correctly.");
+ }
+ });
}
else
{
- Debug.WriteLine("Failed to Reset Log correctly.");
+ // This works better than Data Binding because of the scroll.
+ this.logText.AppendText(Environment.NewLine + e.Log.Content);
+
+ if (this.AutoScroll.IsChecked)
+ {
+ this.logText.ScrollToEnd();
+ }
}
}
- else
+ catch (Exception exc)
{
- // This works better than Data Binding because of the scroll.
- this.logText.AppendText(Environment.NewLine + e.Log.Content);
-
- if (this.AutoScroll.IsChecked)
- {
- this.logText.ScrollToEnd();
- }
+ Debug.WriteLine(exc);
}
}
|