Files
spectreconsole-examples/examples/Cli/Logging/Infrastructure/LogInterceptor.cs
Patrik Svensson a3cc9f5f72 Initial commits
2024-08-05 21:20:18 +02:00

20 lines
525 B
C#

using Logging.Commands;
using Serilog.Core;
using Spectre.Console.Cli;
namespace Logging.Infrastructure;
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;
}
}
}