using PARR.TemplateDistributorWorker;
using PARR.TemplateDistributor;
using Serilog;
using Elastic.CommonSchema.Serilog;

var builder = Host.CreateApplicationBuilder();

builder.Services.AddLogging(config =>
{
    config.ClearProviders();

    var logger = new LoggerConfiguration();

    if (builder.Environment.IsProduction())
        logger.WriteTo.Console(new EcsTextFormatter());
    else
        logger.WriteTo.Console();

    logger.ReadFrom.Configuration(builder.Configuration);

    config.AddSerilog(logger.CreateLogger());
});

builder.Services.InstallTemplateDistributorSerivces(builder.Configuration);
builder.Configuration.AddTemplateDistributorConfigurations(builder.Services);
builder.Services.AddTemplateDistributorSettings(builder.Configuration);

builder.Services.AddHostedService<Worker>();

var host = builder.Build();
host.Run();

