1
0
mirror of https://github.com/nsnail/spectre.console.git synced 2025-04-26 21:22:50 +08:00
2021-03-04 08:39:53 +01:00

20 lines
562 B
C#

using Logging.Commands;
using Serilog.Core;
using Spectre.Console.Cli;
namespace Logging
{
public class LogInterceptor : ICommandInterceptor
{
public static readonly LoggingLevelSwitch LogLevel = new();
public void Intercept(CommandContext context, CommandSettings settings)
{
if (settings is LogCommandSettings logSettings)
{
LoggingEnricher.Path = logSettings.LogFile ?? "application.log";
LogLevel.MinimumLevel = logSettings.LogLevel;
}
}
}
}