支持关闭日志文件写出

This commit is contained in:
nilaoda 2023-06-14 22:14:13 +08:00
parent 8945777e6b
commit 724a5c9fa2
5 changed files with 15 additions and 1 deletions

View File

@ -54,6 +54,7 @@ namespace N_m3u8DL_RE.Common.Resource
public static string cmd_savePattern { get => GetText("cmd_savePattern"); }
public static string cmd_skipDownload { get => GetText("cmd_skipDownload"); }
public static string cmd_noDateInfo { get => GetText("cmd_noDateInfo"); }
public static string cmd_noLog { get => GetText("cmd_noLog"); }
public static string cmd_skipMerge { get => GetText("cmd_skipMerge"); }
public static string cmd_subFormat { get => GetText("cmd_subFormat"); }
public static string cmd_subOnly { get => GetText("cmd_subOnly"); }

View File

@ -100,6 +100,12 @@ namespace N_m3u8DL_RE.Common.Resource
zhTW: "混流時不寫入日期訊息",
enUS: "Date information is not written during muxing"
),
["cmd_noLog"] = new TextContainer
(
zhCN: "关闭日志文件输出",
zhTW: "關閉日誌文件輸出",
enUS: "Disable log file output"
),
["cmd_appendUrlParams"] = new TextContainer
(
zhCN: "将输入Url的Params添加至分片, 对某些网站很有用, 例如 kakao.com",

View File

@ -54,6 +54,7 @@ namespace N_m3u8DL_RE.CommandLine
private readonly static Option<string?> FFmpegBinaryPath = new(new string[] { "--ffmpeg-binary-path" }, description: ResString.cmd_ffmpegBinaryPath) { ArgumentHelpName = "PATH" };
private readonly static Option<string?> BaseUrl = new(new string[] { "--base-url" }, description: ResString.cmd_baseUrl);
private readonly static Option<bool> ConcurrentDownload = new(new string[] { "-mt", "--concurrent-download" }, description: ResString.cmd_concurrentDownload, getDefaultValue: () => false);
private readonly static Option<bool> NoLog = new(new string[] { "--no-log" }, description: ResString.cmd_noLog, getDefaultValue: () => false);
//代理选项
private readonly static Option<bool> UseSystemProxy = new(new string[] { "--use-system-proxy" }, description: ResString.cmd_useSystemProxy, getDefaultValue: () => true);
@ -424,6 +425,7 @@ namespace N_m3u8DL_RE.CommandLine
CustomProxy = bindingContext.ParseResult.GetValueForOption(CustomProxy),
LiveWaitTime = bindingContext.ParseResult.GetValueForOption(LiveWaitTime),
NoDateInfo = bindingContext.ParseResult.GetValueForOption(NoDateInfo),
NoLog = bindingContext.ParseResult.GetValueForOption(NoLog),
};
if (bindingContext.ParseResult.HasOption(CustomHLSMethod)) option.CustomHLSMethod = bindingContext.ParseResult.GetValueForOption(CustomHLSMethod);
@ -484,7 +486,7 @@ namespace N_m3u8DL_RE.CommandLine
var rootCommand = new RootCommand(VERSION_INFO)
{
Input, TmpDir, SaveDir, SaveName, BaseUrl, ThreadCount, DownloadRetryCount, AutoSelect, SkipMerge, SkipDownload, CheckSegmentsCount,
BinaryMerge, DelAfterDone, NoDateInfo, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
BinaryMerge, DelAfterDone, NoDateInfo, NoLog, WriteMetaJson, AppendUrlParams, ConcurrentDownload, Headers, /**SavePattern,**/ SubOnly, SubtitleFormat, AutoSubtitleFix,
FFmpegBinaryPath,
LogLevel, UILanguage, UrlProcessorArgs, Keys, KeyTextFile, DecryptionBinaryPath, UseShakaPackager, MP4RealTimeDecryption,
MuxAfterDone,

View File

@ -41,6 +41,10 @@ namespace N_m3u8DL_RE.CommandLine
/// </summary>
public bool NoDateInfo { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.NoLog"/>.
/// </summary>
public bool NoLog { get; set; }
/// <summary>
/// See: <see cref="CommandInvoker.AutoSelect"/>.
/// </summary>
public bool AutoSelect { get; set; }

View File

@ -73,6 +73,7 @@ namespace N_m3u8DL_RE
//检测更新
CheckUpdateAsync();
Logger.IsWriteFile = !option.NoLog;
Logger.InitLogFile();
Logger.LogLevel = option.LogLevel;
Logger.Info(CommandInvoker.VERSION_INFO);