mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-26 21:22:50 +08:00
20 lines
562 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
} |