Skip to content

Commit

Permalink
Removed ClearProviders
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed May 3, 2024
1 parent bcb6cdd commit 2762694
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/Hosting/Conventions/SerilogHostingConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Conventions.Logging;
using Rocket.Surgery.Hosting;
using Rocket.Surgery.LaunchPad.Serilog;
using Serilog;
Expand Down Expand Up @@ -63,12 +64,12 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder
_options.PreserveStaticLogger,
_options.WriteToProviders
);

if (context.Get<ILoggerFactory>() != null)
// ReSharper disable once NullableWarningSuppressionIsUsed
builder.Services.AddSingleton(context.Get<ILoggerFactory>()!);
}

if (context.Get<ILoggerFactory>() != null)
// ReSharper disable once NullableWarningSuppressionIsUsed
builder.Services.AddSingleton(context.Get<ILoggerFactory>()!);

Check warning on line 71 in src/Hosting/Conventions/SerilogHostingConvention.cs

View check run for this annotation

Codecov / codecov/patch

src/Hosting/Conventions/SerilogHostingConvention.cs#L71

Added line #L71 was not covered by tests

if (_options.WriteToProviders) return;

builder.OnHostStarting(
Expand All @@ -84,4 +85,4 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder
)
);
}
}
}
5 changes: 4 additions & 1 deletion src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Conventions.Logging;
using Serilog;

namespace Rocket.Surgery.LaunchPad.Serilog.Conventions;
Expand Down Expand Up @@ -44,4 +46,5 @@ LoggerConfiguration loggerConfiguration
post.PostConfigure(Options.DefaultName, loggerConfiguration);
}
}
}
}

5 changes: 3 additions & 2 deletions src/Serilog/LaunchPadLoggingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Rocket.Surgery.LaunchPad.Serilog;
/// <summary>
/// RocketSerilogOptions.
/// </summary>
[PublicAPI]
public class LaunchPadLoggingOptions
{
/// <summary>
Expand Down Expand Up @@ -30,10 +31,10 @@ public class LaunchPadLoggingOptions
/// <summary>
/// Base option from the serilog package
/// </summary>
public bool WriteToProviders { get; set; } = false;
public bool WriteToProviders { get; set; }

/// <summary>
/// Base option from the serilog package
/// </summary>
public bool PreserveStaticLogger { get; set; }
}
}

0 comments on commit 2762694

Please sign in to comment.