diff --git a/src/RecurrentTasks/TaskOptions.cs b/src/RecurrentTasks/TaskOptions.cs index dc218aa..2c63511 100644 --- a/src/RecurrentTasks/TaskOptions.cs +++ b/src/RecurrentTasks/TaskOptions.cs @@ -1,9 +1,9 @@ namespace RecurrentTasks { - using Microsoft.Extensions.Logging; using System; using System.Globalization; using System.Threading.Tasks; + using Microsoft.Extensions.Logging; public class TaskOptions { @@ -15,6 +15,9 @@ public class TaskOptions private TimeSpan interval; private TimeSpan firstRunDelay = TimeSpan.FromSeconds(new Random().Next(10, 30)); + /// + /// Custom logger (to use instead of calling loggerFactory.CreateLogger()). + /// public ILogger Logger { get; set; } /// diff --git a/src/RecurrentTasks/TaskOptionsExtensions.cs b/src/RecurrentTasks/TaskOptionsExtensions.cs index 8528fef..de77cca 100644 --- a/src/RecurrentTasks/TaskOptionsExtensions.cs +++ b/src/RecurrentTasks/TaskOptionsExtensions.cs @@ -1,6 +1,8 @@ namespace Microsoft.Extensions.DependencyInjection { using System; + using System.Globalization; + using Microsoft.Extensions.Logging; using RecurrentTasks; public static class TaskOptionsExtensions @@ -27,5 +29,23 @@ public static TaskOptions AutoStart(this TaskOptions taskOptions, uint interval, { return AutoStart(taskOptions, TimeSpan.FromSeconds(interval), TimeSpan.FromSeconds(firstRunDelay)); } + + /// + /// Sets (custom logger to use instead of calling loggerFactory.CreateLogger()). + /// + public static TaskOptions WithLogger(this TaskOptions taskOptions, ILogger logger) + { + taskOptions.Logger = logger; + return taskOptions; + } + + /// + /// Sets , that will be set before is called. + /// + public static TaskOptions WithCulture(this TaskOptions taskOptions, CultureInfo culture) + { + taskOptions.RunCulture = culture; + return taskOptions; + } } }