diff --git a/CodeLegacy/Cli.cs b/CodeLegacy/Cli.cs index 5ec874f..ef29efb 100644 --- a/CodeLegacy/Cli.cs +++ b/CodeLegacy/Cli.cs @@ -22,6 +22,7 @@ namespace Flowframes public static bool CloseMdlDownloaderWhenDone = false; public static bool DontSaveConfig = false; public static bool AutoRun = false; + public static bool Verbose = false; public static float InterpFactor = -1f; public static Implementations.Ai InterpAi = (Implementations.Ai)(-1); public static Enums.Output.Format OutputFormat = (Enums.Output.Format)(-1); @@ -126,6 +127,10 @@ namespace Flowframes "o|output_dir=", "Output folder to save the interpolated video in", v => OutputDir = v.Trim() }, + { + "v|verbose", "Log process outputs", + v => Verbose = v != null + }, { "<>", "Input file(s)", ValidFiles.Add diff --git a/CodeLegacy/IO/Logger.cs b/CodeLegacy/IO/Logger.cs index 0b67716..add03b8 100644 --- a/CodeLegacy/IO/Logger.cs +++ b/CodeLegacy/IO/Logger.cs @@ -30,22 +30,24 @@ namespace Flowframes public bool hidden; public bool replaceLastLine; public string filename; + public bool toConsole; - public LogEntry(string logMessageArg, bool hiddenArg = false, bool replaceLastLineArg = false, string filenameArg = "") + public LogEntry(string logMessageArg, bool hiddenArg = false, bool replaceLastLineArg = false, string filenameArg = "", bool toConsoleArg = true) { logMessage = logMessageArg; hidden = hiddenArg; replaceLastLine = replaceLastLineArg; filename = filenameArg; + toConsole = toConsoleArg; } } private static ConcurrentQueue logQueue = new ConcurrentQueue(); private static readonly string _logPath = Paths.GetLogPath(); - public static void Log(string msg, bool hidden = false, bool replaceLastLine = false, string filename = "") + public static void Log(string msg, bool hidden = false, bool replaceLastLine = false, string filename = "", bool toConsole = true) { - logQueue.Enqueue(new LogEntry(msg, hidden, replaceLastLine, filename)); + logQueue.Enqueue(new LogEntry(msg, hidden, replaceLastLine, filename, toConsole)); ShowNext(); } @@ -70,7 +72,8 @@ namespace Flowframes if (!entry.hidden) _lastUi = msg; - Console.WriteLine(msg); + if (entry.toConsole) + Console.WriteLine(msg); try { diff --git a/CodeLegacy/Media/AvOutputHandler.cs b/CodeLegacy/Media/AvOutputHandler.cs index 8142c6b..a8e0be5 100644 --- a/CodeLegacy/Media/AvOutputHandler.cs +++ b/CodeLegacy/Media/AvOutputHandler.cs @@ -31,7 +31,7 @@ namespace Flowframes.Media line = FormatUtils.BeautifyFfmpegStats(line); appendStr += Environment.NewLine + line; - Logger.Log($"{prefix} {line}", hidden, replaceLastLine, logFilename); + Logger.Log($"{prefix} {line}", hidden, replaceLastLine, logFilename, toConsole: Cli.Verbose || logMode != LogMode.Hidden); if (!hidden && showProgressBar && line.Contains("Time:")) { diff --git a/CodeLegacy/Media/AvProcess.cs b/CodeLegacy/Media/AvProcess.cs index 617ee04..d0a7bb0 100644 --- a/CodeLegacy/Media/AvProcess.cs +++ b/CodeLegacy/Media/AvProcess.cs @@ -115,7 +115,7 @@ namespace Flowframes ffmpeg.PriorityClass = ProcessPriorityClass.BelowNormal; string output = ffmpeg.StandardOutput.ReadToEnd(); ffmpeg.WaitForExit(); - Logger.Log($"Synchronous ffmpeg output:\n{output}", true, false, "ffmpeg"); + Logger.Log($"Synchronous ffmpeg output:\n{output}", true, false, "ffmpeg", toConsole: Cli.Verbose); return output; } diff --git a/CodeLegacy/Os/AiProcess.cs b/CodeLegacy/Os/AiProcess.cs index b384e80..0eb4acd 100644 --- a/CodeLegacy/Os/AiProcess.cs +++ b/CodeLegacy/Os/AiProcess.cs @@ -581,7 +581,7 @@ namespace Flowframes.Os return; logName = ai.LogFilename; - Logger.Log(line, true, false, ai.LogFilename); + Logger.Log(line, true, false, ai.LogFilename, toConsole: Cli.Verbose); void ShowErrorBox(string msg) => UiUtils.ShowMessageBox(msg, UiUtils.MessageType.Error, monospace: true); string lineLow = line.Lower(); diff --git a/CodeLegacy/Os/OsUtils.cs b/CodeLegacy/Os/OsUtils.cs index 3c43fb4..624c1d3 100644 --- a/CodeLegacy/Os/OsUtils.cs +++ b/CodeLegacy/Os/OsUtils.cs @@ -334,20 +334,6 @@ namespace Flowframes.Os return string.Join(";", newPaths.Select(x => x.Replace("\\", "/"))) + ";"; } - public static bool IsStillRunning(Func proc) // For .NET Core migration: Func (nullable) - { - var p = proc(); // Snapshot of the process to avoid race condition - - try - { - return p is null || !p.HasExited; - } - catch - { - return false; - } - } - public enum DevModeState { Disabled, Enabled, Unknown } public static DevModeState GetDeveloperModeState() diff --git a/CodeLegacy/Program.cs b/CodeLegacy/Program.cs index 5c58595..aec3783 100644 --- a/CodeLegacy/Program.cs +++ b/CodeLegacy/Program.cs @@ -185,7 +185,7 @@ namespace Flowframes // Logger.Log($"Disk space check for '{drivePath}/': {spaceGb} GB free, next check in {nextWaitTimeMs / 1024} sec", true); - if (!Interpolate.canceled && OsUtils.IsStillRunning(() => AiProcess.lastAiProcess) && lowDiskSpace) + if (!Interpolate.canceled && (AiProcess.lastAiProcess != null && !AiProcess.lastAiProcess.HasExited) && lowDiskSpace) { if (tooLowDiskSpace) {