using Microsoft.Extensions.Configuration;
using Serilog.Core;
using Serilog.Events;

namespace NetworkResurrector.Agent.Extensions.Serilog
{
    public class AgentCodeEventEnricher : ILogEventEnricher
    {
        private readonly IConfiguration _configuration;

        public AgentCodeEventEnricher(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            var agentCode = _configuration.GetValue<string>("Agent:Code") ?? "N/A";
            logEvent.AddOrUpdateProperty(propertyFactory.CreateProperty("Agent", agentCode));
        }
    }
}
