using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;

// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/License for full license details.

namespace EonaCat.Logger.EonaCatCoreLogger.Extensions
{
    public static class ElasticSearchLoggerFactoryExtensions
    {
        public static ILoggingBuilder AddEonaCatElasticSearchLogger(this ILoggingBuilder builder, Action<ElasticSearchLoggerOptions> configure)
        {
            var options = new ElasticSearchLoggerOptions();
            configure?.Invoke(options);
            builder.Services.AddSingleton<ILoggerProvider>(new ElasticSearchLoggerProvider(options));
            return builder;
        }
    }
}
