using Dalamud.Plugin.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;

namespace HellionChat.Infrastructure.Logging;

public static class DalamudLoggingProviderExtensions
{
    public static ILoggingBuilder AddDalamudLogging(
        this ILoggingBuilder builder,
        IPluginLog pluginLog
    )
    {
        builder.ClearProviders();
        builder.Services.TryAddEnumerable(
            ServiceDescriptor.Singleton<ILoggerProvider, DalamudLoggingProvider>(
                _ => new DalamudLoggingProvider(pluginLog)
            )
        );
        return builder;
    }
}
