using Serilog;
using Serilog.Events;
using Tiku.Worker;

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
    .Enrich.FromLogContext()
    .WriteTo.Console()
    .CreateBootstrapLogger();

try
{
    Log.Information("Starting TIKU Worker");
    var builder = Host.CreateApplicationBuilder(args);
    builder.AddWorkerServices();
    await builder.Build().RunAsync();
}
catch (Exception exception)
{
    Log.Fatal(exception, "TIKU Worker terminated unexpectedly");
    throw;
}
finally
{
    await Log.CloseAndFlushAsync();
}