From 557b0d3a308aa9f8ec666b3c43e4b76a9bccbabe Mon Sep 17 00:00:00 2001 From: n00mkrad <61149547+n00mkrad@users.noreply.github.com> Date: Sun, 11 Jan 2026 17:39:49 +0100 Subject: [PATCH] Logging improvements, add "Copy" btn to error message boxes --- CodeLegacy/Forms/MessageForm.cs | 27 ++++++++++++++++++++++++++- CodeLegacy/Main/Export.cs | 2 +- CodeLegacy/Os/AiProcess.cs | 14 +++++++++++--- CodeLegacy/Ui/UiUtils.cs | 4 ++-- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/CodeLegacy/Forms/MessageForm.cs b/CodeLegacy/Forms/MessageForm.cs index d2e7169..ea497cf 100644 --- a/CodeLegacy/Forms/MessageForm.cs +++ b/CodeLegacy/Forms/MessageForm.cs @@ -2,6 +2,7 @@ using System; using System.Drawing; using System.Windows.Forms; +using static Flowframes.Ui.UiUtils; namespace Flowframes.Forms { @@ -10,17 +11,32 @@ namespace Flowframes.Forms private string _text = ""; private string _title = ""; private MessageBoxButtons _btns; + private MessageType _type = MessageType.Message; private bool _monospace; private bool _dialogResultSet = false; + public MessageForm(string text, MessageType type, MessageBoxButtons buttons = MessageBoxButtons.OK, bool monospace = false) + { + _type = type; + _text = text; + _title = $"{type}"; + _btns = buttons; + _monospace = monospace; + Init(); + } + public MessageForm(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.OK, bool monospace = false) { _text = text; _title = title; _btns = buttons; _monospace = monospace; + Init(); + } + private void Init () + { InitializeComponent(); } @@ -28,6 +44,7 @@ namespace Flowframes.Forms { Text = _title; textLabel.Text = _text; + bool isError = _type == MessageType.Error; if (_monospace) { @@ -36,9 +53,15 @@ namespace Flowframes.Forms if(_btns == MessageBoxButtons.OK) { - SetButtons(true, false, false); + SetButtons(true, isError, false); btn1.Text = "OK"; AcceptButton = btn1; + + if(isError) + { + btn2.Text = "Copy"; + btn2.Click += (s, ev) => Clipboard.SetText(_text); + } } else if(_btns == MessageBoxButtons.YesNo) { @@ -95,6 +118,8 @@ namespace Flowframes.Forms DialogResult = DialogResult.Yes; else if (_btns == MessageBoxButtons.YesNoCancel) // No Button DialogResult = DialogResult.No; + else + return; _dialogResultSet = true; Close(); diff --git a/CodeLegacy/Main/Export.cs b/CodeLegacy/Main/Export.cs index 1e9aa6e..1e218bd 100644 --- a/CodeLegacy/Main/Export.cs +++ b/CodeLegacy/Main/Export.cs @@ -377,7 +377,7 @@ namespace Flowframes.Main { if (!File.Exists(outVideo)) { - I.Cancel($"No video was encoded!\n\nFFmpeg Output:\n{AvProcess.lastOutputFfmpeg}"); + I.Cancel($"No video was encoded! Check logs and error messages.{(AvProcess.lastOutputFfmpeg.IsEmpty() ? "" : $"\n\nFFmpeg Output:\n{AvProcess.lastOutputFfmpeg}")}"); return; } diff --git a/CodeLegacy/Os/AiProcess.cs b/CodeLegacy/Os/AiProcess.cs index fa7ee86..93872d1 100644 --- a/CodeLegacy/Os/AiProcess.cs +++ b/CodeLegacy/Os/AiProcess.cs @@ -563,9 +563,17 @@ namespace Flowframes.Os private static readonly Regex FfmpegLogMemAddr = new Regex(@" @\s*(?:0x)?(?[0-9A-Fa-f]{8,16})(?=\])", RegexOptions.Compiled); - private static string GetLastLogLines(string logName, int lineCount = 6, bool beautify = true) + private static string GetLastLogLines(string log = "", int lineCount = 6, bool beautify = true) { - var lll = Logger.GetSessionLogLastLines(logName, lineCount); + if (log.IsEmpty()) + { + if (logName.IsNotEmpty()) + log = logName; + else + return "N/A"; + } + + var lll = Logger.GetSessionLogLastLines(log, lineCount); if (!beautify) return string.Join("\n", lll); @@ -668,7 +676,7 @@ namespace Flowframes.Os if (!hasShownError && line.Contains("vapoursynth.Error:")) { hasShownError = true; - ShowErrorBox($"VapourSynth Error:\n\n{line}"); + ShowErrorBox($"VapourSynth Error:\n\n{GetLastLogLines()}"); } } diff --git a/CodeLegacy/Ui/UiUtils.cs b/CodeLegacy/Ui/UiUtils.cs index 410868f..19e2070 100644 --- a/CodeLegacy/Ui/UiUtils.cs +++ b/CodeLegacy/Ui/UiUtils.cs @@ -9,7 +9,7 @@ using System.Windows.Forms; namespace Flowframes.Ui { - class UiUtils + public class UiUtils { public static void InitCombox(ComboBox box, int index) { @@ -100,7 +100,7 @@ namespace Flowframes.Ui if (type == MessageType.Warning) icon = MessageBoxIcon.Warning; else if (type == MessageType.Error) icon = MessageBoxIcon.Error; - var msgForm = new MessageForm(text, type.ToString(), monospace: monospace) { TopMost = true }; + var msgForm = new MessageForm(text, type, monospace: monospace) { TopMost = true }; Program.mainForm.Invoke(() => msgForm.ShowDialog()); return DialogResult.OK; }