diff --git a/src/EverythingToJpeg.App/App.xaml b/src/EverythingToJpeg.App/App.xaml index 1510506..430b975 100644 --- a/src/EverythingToJpeg.App/App.xaml +++ b/src/EverythingToJpeg.App/App.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:local="clr-namespace:EverythingToJpeg.App" - ShutdownMode="OnExplicitShutdown"> + ShutdownMode="OnLastWindowClose"> diff --git a/src/EverythingToJpeg.App/App.xaml.cs b/src/EverythingToJpeg.App/App.xaml.cs index 95b0549..4796741 100644 --- a/src/EverythingToJpeg.App/App.xaml.cs +++ b/src/EverythingToJpeg.App/App.xaml.cs @@ -79,6 +79,11 @@ public partial class App : Application private async Task RunQuickAsync(IReadOnlyList files) { + var logPath = Path.Combine(Path.GetTempPath(), "EverythingToJpeg_quick.log"); + var log = new System.Text.StringBuilder(); + log.AppendLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] Quick start, {files.Count} file(s)"); + foreach (var f in files) log.AppendLine($" src: {f}"); + var progress = new QuickProgressWindow(files.Count); progress.Show(); @@ -87,14 +92,28 @@ public partial class App : Application var options = ConvertOptions.Quick(); var reporter = new Progress(p => progress.Report(p)); var results = await Engine.ConvertManyAsync(files, options, reporter); + + foreach (var r in results) + { + log.AppendLine($" [{r.Status}] {Path.GetFileName(r.SourcePath)} → {r.OutputPaths.Count} output(s)"); + if (r.Message is { Length: > 0 }) log.AppendLine($" msg: {r.Message}"); + if (r.Error is not null) log.AppendLine($" err: {r.Error}"); + foreach (var o in r.OutputPaths) log.AppendLine($" out: {o}"); + } + progress.Finish(results); } catch (Exception ex) { - MessageBox.Show($"변환 중 오류: {ex.Message}", "EverythingToJpeg", + log.AppendLine($" EXCEPTION {ex.GetType().Name}: {ex.Message}"); + log.AppendLine(ex.ToString()); + try { progress.Close(); } catch { } + MessageBox.Show($"변환 중 오류: {ex.Message}\n\n로그: {logPath}", "EverythingToJpeg", MessageBoxButton.OK, MessageBoxImage.Error); - progress.Close(); - Shutdown(1); + } + finally + { + try { File.WriteAllText(logPath, log.ToString()); } catch { } } } }