static async Task Main(string[] args) { var version = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location).ProductVersion; Console.WriteLine($"RBL DNS Aggregator {version}"); Console.WriteLine("https://github.com/bluewalk/rbldns-aggregator\n"); Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .MinimumLevel.Debug() .WriteTo.ColoredConsole( EnvironmentExtensions.GetEnvironmentVariable <LogEventLevel>("LOG_LEVEL", LogEventLevel.Information) ).CreateLogger(); AppDomain.CurrentDomain.DomainUnload += (sender, eventArgs) => Log.CloseAndFlush(); var builder = new HostBuilder() .ConfigureServices((hostContext, services) => { services.AddOptions(); services.AddSingleton <IHostedService, Logic>(); }) .UseSerilog(); await builder.RunConsoleAsync(); }
static async Task Main(string[] args) { var version = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location).ProductVersion; Console.WriteLine($"Anysee Transcode {version}"); Console.WriteLine("https://github.com/bluewalk/AnyseeTranscode\n"); Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) .WriteTo.Console(EnvironmentExtensions.GetEnvironmentVariable("LOG_LEVEL", LogEventLevel.Information), "{Timestamp:yyyy-MM-dd HH:mm:ss zzz} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}", theme: AnsiConsoleTheme.Code ).CreateLogger(); AppDomain.CurrentDomain.DomainUnload += (sender, eventArgs) => Log.CloseAndFlush(); var builder = new HostBuilder() .ConfigureServices((hostContext, services) => { services.AddOptions(); services.AddSingleton <IHostedService, Logic>(); }) .UseSerilog(); await builder.RunConsoleAsync(); }
static void Main(string[] args) { var program = new ConsoleProgram(); Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning) .MinimumLevel.Debug() .WriteTo.Debug() .WriteTo.Console( EnvironmentExtensions.GetEnvironmentVariable("LOG_LEVEL", LogEventLevel.Information), "{Timestamp:yyyy-MM-dd HH:mm:ss zzz} [{Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}", theme: AnsiConsoleTheme.Code ).CreateLogger(); var version = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location).ProductVersion; System.Console.WriteLine($"NukiBridge2Mqtt version {version}"); System.Console.WriteLine("https://github.com/bluewalk/NukiBridge2Mqtt/\n"); // Fire and forget Task.Run(() => { program.Start(args.FirstOrDefault()?.Equals("docker") == true); waitHandle.WaitOne(); }); // Handle Control+C or Control+Break System.Console.CancelKeyPress += (o, e) => { System.Console.WriteLine("Exit"); program.Stop(); // Allow the manin thread to continue and exit... waitHandle.Set(); }; // Wait waitHandle.WaitOne(); }