/// <summary> /// Add FluentMigratorConsoleLoggerProvider with setting in 'options' parameter /// </summary> /// <param name="loggingBuilder"></param> /// <param name="options"></param> /// <param name="clearLoggingProviders">If true, all log-providers is first removed</param> /// <returns></returns> public static ILoggingBuilder AddFluentMigratorConsoleLogger( this ILoggingBuilder loggingBuilder, FluentMigratorLoggerOptions options, bool clearLoggingProviders = false) { if (clearLoggingProviders) { loggingBuilder.ClearProviders(); } if (options == null) { var configuration = GetConfiguration(loggingBuilder, null); options = new FluentMigratorLoggerOptions { ShowSql = configuration?.IsMigrationConsoleLogShowSqlEnabled() ?? false, ShowElapsedTime = configuration?.IsMigrationLogConsoleShowElapsedTimeEnabled() ?? false }; } loggingBuilder.Services.RemoveFluentMigratorLoggerOptions(); loggingBuilder.Services.TryAddSingleton <IOptions <FluentMigratorLoggerOptions> >(new OptionsWrapper <FluentMigratorLoggerOptions>(options)); loggingBuilder.Services.TryAddSingleton <ILoggerProvider, FluentMigratorConsoleLoggerProvider>(); return(loggingBuilder); }
/// <summary> /// Remove all log-providers and add FluentMigratorConsoleLoggerProvider if enabled by configuration /// </summary> /// <param name="loggingBuilder"></param> /// <param name="configuration"></param> /// <returns></returns> public static ILoggingBuilder AddFluentMigratorConsoleLogger( this ILoggingBuilder loggingBuilder, IConfiguration configuration = null) { configuration = GetConfiguration(loggingBuilder, configuration); string disabledReason = null; if (configuration == null || !configuration.IsMigrationConsoleLogEnabledInternal(out disabledReason)) { disabledReason = disabledReason ?? "by missing configuration"; loggingBuilder.Services.RemoveFluentMigratorLoggerOptions(); loggingBuilder.Services.Remove(new ServiceDescriptor(typeof(ILoggerProvider), typeof(FluentMigratorConsoleLoggerProvider))); if (MigrationConsoleLoggingDisabledReported == false) { MigrationConsoleLoggingDisabledReported = true; Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine($"Migration Console logging is turned off {disabledReason}"); Console.ResetColor(); } return(loggingBuilder); } var options = new FluentMigratorLoggerOptions { ShowSql = configuration.IsMigrationConsoleLogShowSqlEnabled(), ShowElapsedTime = configuration.IsMigrationLogConsoleShowElapsedTimeEnabled() }; return(loggingBuilder.AddFluentMigratorConsoleLogger(options)); }
public ExtendedOracleProcessorBase(OracleBaseDbFactory factory, IMigrationGenerator generator, ILogger logger, IOptionsSnapshot <ProcessorOptions> options, IOptionsSnapshot <RunnerOptions> runnerOptions, IConnectionStringAccessor connectionStringAccessor, IExtendedMigrationGenerator <ExtendedOracleMigrationGenerator> extendedGenerator, IDbMigrationConfig migrationConfig, IMigrationSourceItem migrationSourceItem = null, IVersionTableMetaData versionTableMetaData = null, IOptions <FluentMigratorLoggerOptions> loggerGenOptions = null, IOptions <LogFileFluentMigratorLoggerOptions> logFileOptions = null) : base(ProcessorIds.OracleProcessorId, factory, generator, logger, options, connectionStringAccessor) { RunnerOptions = runnerOptions; MigrationConfig = migrationConfig; VersionTableMetaData = versionTableMetaData; LoggerOptions = loggerGenOptions?.Value; LoggerFileOptions = logFileOptions?.Value; IsSqlLogEnabled = (LoggerOptions?.ShowSql ?? false) || (LoggerFileOptions?.ShowSql ?? false); ExtendedGenerator = extendedGenerator; MigrationMetadata = new MigrationMetadata(migrationSourceItem).InitMetadata(MigrationConfig); ConnectionStringFunc = () => connectionStringAccessor.ConnectionString; Initialize(); }
public void Setup() { _options = new FluentMigratorLoggerOptions(); _output = new StringWriter(); _loggerFactory = new LoggerFactory(); _loggerFactory.AddProvider(new TextWriterLoggerProvider(_output, _options)); _logger = _loggerFactory.CreateLogger("Test"); }
public static ILoggingBuilder AddFluentMigratorConsoleLogger( this ILoggingBuilder loggingBuilder, FluentMigratorLoggerOptions options, bool clearProviders = false) { if (clearProviders) { loggingBuilder.ClearProviders(); } return(loggingBuilder.AddProvider(new FluentMigratorConsoleLoggerProvider(new OptionsWrapper <FluentMigratorLoggerOptions>(options)))); }
/// <summary> /// Add FluentMigratorConsoleLoggerProvider with setting in 'options' parameter /// </summary> /// <param name="loggingBuilder"></param> /// <param name="options"></param> /// <param name="clearLoggingProviders">If true, all log-providers is first removed</param> /// <returns></returns> public static ILoggingBuilder AddFluentMigratorConsoleLogger( this ILoggingBuilder loggingBuilder, FluentMigratorLoggerOptions options, bool clearLoggingProviders = false) { if (clearLoggingProviders) { loggingBuilder.ClearProviders(); } loggingBuilder.Services.AddSingleton <IOptions <FluentMigratorLoggerOptions> >(new OptionsWrapper <FluentMigratorLoggerOptions>(options)); loggingBuilder.Services.AddSingleton <ILoggerProvider, FluentMigratorConsoleLoggerProvider>(); return(loggingBuilder); }
/// <summary> /// Remove all log-providers and add FluentMigratorConsoleLoggerProvider if enabled by configuration /// </summary> /// <param name="loggingBuilder"></param> /// <param name="configuration"></param> /// <returns></returns> public static ILoggingBuilder AddFluentMigratorConsoleLogger( this ILoggingBuilder loggingBuilder, IConfiguration configuration = null) { configuration = GetConfiguration(loggingBuilder, configuration); if (configuration == null || !configuration.IsMigrationConsoleLogEnabled()) { return(loggingBuilder); } var options = new FluentMigratorLoggerOptions { ShowSql = configuration.IsMigrationLogShowSqlEnabled(), ShowElapsedTime = configuration.IsMigrationLogShowElapsedTimeEnabled() }; return(loggingBuilder.AddFluentMigratorConsoleLogger(options, true)); }
public static ILoggingBuilder AddFluentMigratorConsoleLogger( this ILoggingBuilder loggingBuilder, IConfiguration configuration = null) { configuration = GetConfiguration(loggingBuilder, configuration); if (configuration == null || !configuration.IsConsoleLogEnabled()) { return(loggingBuilder); } loggingBuilder.ClearProviders(); var options = new FluentMigratorLoggerOptions { ShowSql = configuration.IsMigrationLogShowSqlEnabled(), ShowElapsedTime = configuration.IsMigrationLogShowElapsedTimeEnabled() }; loggingBuilder.Services.AddSingleton <IOptions <FluentMigratorLoggerOptions> >(new OptionsWrapper <FluentMigratorLoggerOptions>(options)); return(loggingBuilder.AddFluentMigratorConsoleLogger(options)); }
/// <inheritdoc /> public FluentMigratorRunnerLogger(TextWriter output, TextWriter error, FluentMigratorLoggerOptions options) : base(options) { _output = output; _error = error; }
public MigrationLogger(ILogger logger, FluentMigratorLoggerOptions options) : base(options) { _logger = logger; }
/// <inheritdoc /> public TextWriterLogger(TextWriter output, FluentMigratorLoggerOptions options) : base(output, output, options) { }
public TextWriterLoggerProvider(TextWriter writer, FluentMigratorLoggerOptions options) { _writer = writer; _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="FluentMigratorConsoleLogger"/> class. /// </summary> /// <param name="options">The logger options</param> public FluentMigratorConsoleLogger(FluentMigratorLoggerOptions options) : base(Console.Out, Console.Error, options) { }
/// <summary> /// Initializes a new instance of the <see cref="StopOnErrorLogger"/> class. /// </summary> /// <param name="options">The logger options</param> public StopOnErrorLogger(FluentMigratorLoggerOptions options) : base(options) { }
/// <summary> /// Initializes a new instance of the <see cref="StopOnErrorLoggerProvider"/> class. /// </summary> /// <param name="options">The logger options</param> public StopOnErrorLoggerProvider(IOptions <FluentMigratorLoggerOptions> options) { _options = options.Value; }
public FluentMigratorFileLoggerProvider(string path, IOptions <FluentMigratorLoggerOptions> options) { _options = options.Value; _output = new StreamWriter(path, false, Encoding.UTF8, 1); }
/// <summary> /// Initializes a new instance of the <see cref="FluentMigratorConsoleLoggerProvider"/> class. /// </summary> /// <param name="options">The logger options</param> public FluentMigratorConsoleLoggerProvider(IOptions <FluentMigratorLoggerOptions> options) { _options = options.Value; Console.ResetColor(); }
/// <summary> /// Initializes a new instance of the <see cref="FluentMigratorLogger"/> class. /// </summary> /// <param name="options">The logger options</param> protected FluentMigratorLogger(FluentMigratorLoggerOptions options) { _options = options; }
/// <inheritdoc /> public TextLineLogger([NotNull, ItemNotNull] ICollection <string> lines, [NotNull] FluentMigratorLoggerOptions options) : base(options) { _lines = lines; _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="TextLineLoggerProvider"/> class. /// </summary> /// <param name="lines"></param> /// <param name="options"></param> public TextLineLoggerProvider([NotNull, ItemNotNull] ICollection <string> lines, FluentMigratorLoggerOptions options = null) { _lines = lines; _options = options ?? new FluentMigratorLoggerOptions(); }