/// <summary> /// Enables SimpleLog framework /// </summary> /// <param name="services"></param> /// <param name="configuration"></param> public static void AddSimpleLog(this IServiceCollection services) { //Logging to console by default var options = new LogBuilder(); options.AddConsoleTarget(); services.AddSingleton(options); services.AddScoped <SimpleLogger>(); }
/// <summary> /// Enables SimpleLog framework /// </summary> /// <param name="services"></param> /// <param name="configuration"></param> public static void AddSimpleLog(this IServiceCollection services, Action <LogBuilder> configuration) { var options = new LogBuilder(); configuration(options); services.AddSingleton(options); //If not targets are added during configuration //add a default console target if (!options.LogTargets.Any()) { options.AddConsoleTarget(); } services.AddTransient <ILogger, SimpleLogger>(); }
/// <summary> /// Sets the enabled log levels for the logging framework. /// </summary> /// <param name="options"></param> /// <param name="minLevel"></param> /// <param name="maxLevel"></param> public static void EnableLevels(this LogBuilder options, LogLevel minLevel = LogLevel.Information, LogLevel maxLevel = LogLevel.Critical) { options.EnabledLevels = ClampLogLevels(minLevel, maxLevel).ToArray(); }
/// <summary> /// Sets the enabled log levels for the logging framework. /// </summary> /// <param name="options"></param> /// <param name="enabledLevels"></param> public static void EnableLevels(this LogBuilder options, params LogLevel[] enabledLevels) { options.EnabledLevels = enabledLevels; }
public SimpleLogger(LogBuilder options) { Options = options; }