diff --git a/sandbox/MultiContainedApp/Program.cs b/sandbox/MultiContainedApp/Program.cs index 3f87805..eb38880 100644 --- a/sandbox/MultiContainedApp/Program.cs +++ b/sandbox/MultiContainedApp/Program.cs @@ -10,7 +10,8 @@ class Program { static async Task Main(string[] args) { - await BatchHost.CreateDefaultBuilder().RunBatchEngineAsync(args); + await BatchHost.CreateDefaultBuilder() + .RunBatchEngineAsync(args); } } diff --git a/src/MicroBatchFramework/BatchEngineHostBuilderExtensions.cs b/src/MicroBatchFramework/BatchEngineHostBuilderExtensions.cs index c92cbd9..7a7002c 100644 --- a/src/MicroBatchFramework/BatchEngineHostBuilderExtensions.cs +++ b/src/MicroBatchFramework/BatchEngineHostBuilderExtensions.cs @@ -15,7 +15,7 @@ public static class BatchEngineHostBuilderExtensions const string ListCommand = "list"; const string HelpCommand = "help"; - public static IHostBuilder UseBatchEngine(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null, bool useSimpleConosoleLogger = true) + public static IHostBuilder UseBatchEngine(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null) { if (args.Length == 0 || (args.Length == 1 && args[0].Equals(ListCommand, StringComparison.OrdinalIgnoreCase))) { @@ -76,20 +76,15 @@ public static IHostBuilder UseBatchEngine(this IHostBuilder hostBuilder, string[ } }); - if (useSimpleConosoleLogger) - { - hostBuilder = hostBuilder.ConfigureLogging(x => x.AddSimpleConsole()); - } - return hostBuilder.UseConsoleLifetime(); } - public static Task RunBatchEngineAsync(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null, bool useSimpleConosoleLogger = true) + public static Task RunBatchEngineAsync(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null) { - return UseBatchEngine(hostBuilder, args, interceptor, useSimpleConosoleLogger).Build().RunAsync(); + return UseBatchEngine(hostBuilder, args, interceptor).Build().RunAsync(); } - public static IHostBuilder UseBatchEngine(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null, bool useSimpleConosoleLogger = true) + public static IHostBuilder UseBatchEngine(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null) where T : BatchBase { var method = typeof(T).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); @@ -151,18 +146,13 @@ public static IHostBuilder UseBatchEngine(this IHostBuilder hostBuilder, stri services.AddTransient(); }); - if (useSimpleConosoleLogger) - { - hostBuilder = hostBuilder.ConfigureLogging(x => x.AddSimpleConsole()); - } - return hostBuilder.UseConsoleLifetime(); } - public static Task RunBatchEngineAsync(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null, bool useSimpleConosoleLogger = true) + public static Task RunBatchEngineAsync(this IHostBuilder hostBuilder, string[] args, IBatchInterceptor interceptor = null) where T : BatchBase { - return UseBatchEngine(hostBuilder, args, interceptor, useSimpleConosoleLogger).Build().RunAsync(); + return UseBatchEngine(hostBuilder, args, interceptor).Build().RunAsync(); } static void ShowMethodList() diff --git a/src/MicroBatchFramework/BatchHost.cs b/src/MicroBatchFramework/BatchHost.cs index 4cbfbbe..d86e53c 100644 --- a/src/MicroBatchFramework/BatchHost.cs +++ b/src/MicroBatchFramework/BatchHost.cs @@ -28,7 +28,7 @@ public static class BatchHost /// and configure the to log to the console, /// /// The initialized . - public static IHostBuilder CreateDefaultBuilder(bool useSimpleConosoleLogger = true) => CreateDefaultBuilder(useSimpleConosoleLogger, LogLevel.Debug); + public static IHostBuilder CreateDefaultBuilder(bool useSimpleConsoleLogger = true) => CreateDefaultBuilder(useSimpleConsoleLogger, LogLevel.Debug); /// /// Initializes a new instance of the class with pre-configured defaults. @@ -41,10 +41,10 @@ public static class BatchHost /// load from environment variables, /// and configure the to log to the console, /// - /// + /// /// /// The initialized . - public static IHostBuilder CreateDefaultBuilder(bool useSimpleConosoleLogger, LogLevel minSimpleConsoleLoggerLogLevel) => CreateDefaultBuilder(useSimpleConosoleLogger, minSimpleConsoleLoggerLogLevel, ""); + public static IHostBuilder CreateDefaultBuilder(bool useSimpleConsoleLogger, LogLevel minSimpleConsoleLoggerLogLevel) => CreateDefaultBuilder(useSimpleConsoleLogger, minSimpleConsoleLoggerLogLevel, ""); /// /// Initializes a new instance of the class with pre-configured defaults. @@ -57,17 +57,17 @@ public static class BatchHost /// load from environment variables, /// and configure the to log to the console, /// - /// + /// /// /// /// The initialized . - public static IHostBuilder CreateDefaultBuilder(bool useSimpleConosoleLogger, LogLevel minSimpleConsoleLoggerLogLevel, string hostEnvironmentVariable) + public static IHostBuilder CreateDefaultBuilder(bool useSimpleConsoleLogger, LogLevel minSimpleConsoleLoggerLogLevel, string hostEnvironmentVariable) { var builder = new HostBuilder(); ConfigureHostConfigurationDefault(builder, hostEnvironmentVariable); ConfigureAppConfigurationDefault(builder); - ConfigureLoggingDefault(builder, useSimpleConosoleLogger, minSimpleConsoleLoggerLogLevel); + ConfigureLoggingDefault(builder, useSimpleConsoleLogger, minSimpleConsoleLoggerLogLevel); return builder; } @@ -111,9 +111,9 @@ internal static void ConfigureAppConfigurationDefault(IHostBuilder builder) }); } - internal static void ConfigureLoggingDefault(IHostBuilder builder, bool useSimpleConosoleLogger, LogLevel minSimpleConsoleLoggerLogLevel) + internal static void ConfigureLoggingDefault(IHostBuilder builder, bool useSimpleConsoleLogger, LogLevel minSimpleConsoleLoggerLogLevel) { - if (useSimpleConosoleLogger) + if (useSimpleConsoleLogger) { builder.ConfigureLogging(logging => {