Adding ffmpeg debug reporting config

This commit is contained in:
= 2025-12-15 12:39:56 -05:00
parent e6075be886
commit 7d2e652dc5
3 changed files with 15 additions and 4 deletions

View File

@ -61,6 +61,9 @@ namespace OF_DL.Entities
public int ApiRateLimitWindowSeconds { get; set; } = 10;
public int MaxLogBodyLength { get; set; } = 2000;
public bool EnableJsonResponseBodyRawLogs { get; set; } = false;
[ToggleableConfig]
public bool EnableFfmpegReport { get; set; } = true;
public string FfmpegReportPath { get; set; } = Path.Combine("logs", "diagnostics", "ffmpeg");
// Indicates if you want to download only on specific dates.
[ToggleableConfig]

View File

@ -57,6 +57,9 @@ namespace OF_DL.Entities
int MaxLogBodyLength { get; set; }
bool EnableJsonResponseBodyRawLogs { get; set; }
bool EnableFfmpegReport { get; set; }
string FfmpegReportPath { get; set; }
}
}

View File

@ -632,8 +632,11 @@ public class DownloadHelper : IDownloadHelper
// Configure ffmpeg log level and optional report file location
bool ffmpegDebugLogging = Log.IsEnabled(Serilog.Events.LogEventLevel.Debug);
bool enableReport = downloadConfig.EnableFfmpegReport;
string logLevelArgs = ffmpegDebugLogging || downloadConfig.LoggingLevel is LoggingLevel.Verbose or LoggingLevel.Debug
bool includeReport = enableReport && (ffmpegDebugLogging || downloadConfig.LoggingLevel is LoggingLevel.Verbose or LoggingLevel.Debug);
string logLevelArgs = includeReport
? "-loglevel debug -report"
: downloadConfig.LoggingLevel switch
{
@ -644,10 +647,12 @@ public class DownloadHelper : IDownloadHelper
_ => string.Empty
};
if (logLevelArgs.Contains("-report", StringComparison.OrdinalIgnoreCase))
if (includeReport)
{
// Direct ffmpeg report files into the same logs directory Serilog uses (relative to current working directory)
string logDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "logs"));
string reportDir = string.IsNullOrWhiteSpace(downloadConfig.FfmpegReportPath)
? Path.Combine("logs", "diagnostics", "ffmpeg")
: downloadConfig.FfmpegReportPath;
string logDir = Path.GetFullPath(reportDir);
Directory.CreateDirectory(logDir);
string ffReportPath = Path.Combine(logDir, "ffmpeg-%p-%t.log"); // ffmpeg will replace %p/%t
Environment.SetEnvironmentVariable("FFREPORT", $"file={ffReportPath}:level=32");