mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
19 lines
503 B
C#
19 lines
503 B
C#
using Serilog.Core;
|
|
using Spectre.Console.Cli;
|
|
|
|
namespace Spectre.Console.Examples;
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|