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

namespace EonaCat.Logger.EonaCatCoreLogger.Extensions
{
    public static class DatabaseLoggerFactoryExtensions
    {
        public static ILoggingBuilder AddEonaCatDatabaseLogger(this ILoggingBuilder builder, Action<DatabaseLoggerOptions> configure)
        {
            var options = new DatabaseLoggerOptions();
            configure?.Invoke(options);

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