CLI/debug: Don't log process output to console by default (only with -v/--verbose)

This commit is contained in:
n00mkrad
2025-12-21 18:30:03 +01:00
parent 1d08960203
commit aed095f88b
7 changed files with 16 additions and 22 deletions

View File

@@ -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

View File

@@ -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<LogEntry> logQueue = new ConcurrentQueue<LogEntry>();
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
{

View File

@@ -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:"))
{

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -334,20 +334,6 @@ namespace Flowframes.Os
return string.Join(";", newPaths.Select(x => x.Replace("\\", "/"))) + ";";
}
public static bool IsStillRunning(Func<Process> proc) // For .NET Core migration: Func<Process?> (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()

View File

@@ -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)
{