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 UdpLoggerFactoryExtensions
    {
        public static ILoggingBuilder AddEonaCatUdpLogger(this ILoggingBuilder builder, Action<UdpLoggerOptions> configure)
        {
            var options = new UdpLoggerOptions();
            configure?.Invoke(options);

            builder.Services.AddSingleton<ILoggerProvider>(new UdpLoggerProvider(options));
            return builder;
        }
    }
}
