From 276269461a24d1bcd1bb59caa996564f139c3466 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Fri, 3 May 2024 11:28:20 -0400 Subject: [PATCH 1/2] Removed ClearProviders --- src/Hosting/Conventions/SerilogHostingConvention.cs | 11 ++++++----- .../Conventions/ConfigureOptionsLoggingConvention.cs | 5 ++++- src/Serilog/LaunchPadLoggingOptions.cs | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Hosting/Conventions/SerilogHostingConvention.cs b/src/Hosting/Conventions/SerilogHostingConvention.cs index f5c26fa16..295f0a1fe 100644 --- a/src/Hosting/Conventions/SerilogHostingConvention.cs +++ b/src/Hosting/Conventions/SerilogHostingConvention.cs @@ -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; @@ -63,12 +64,12 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder _options.PreserveStaticLogger, _options.WriteToProviders ); - - if (context.Get() != null) - // ReSharper disable once NullableWarningSuppressionIsUsed - builder.Services.AddSingleton(context.Get()!); } + if (context.Get() != null) + // ReSharper disable once NullableWarningSuppressionIsUsed + builder.Services.AddSingleton(context.Get()!); + if (_options.WriteToProviders) return; builder.OnHostStarting( @@ -84,4 +85,4 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder ) ); } -} \ No newline at end of file +} diff --git a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs index 29b1badcf..35a44f63f 100644 --- a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs +++ b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs @@ -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; @@ -44,4 +46,5 @@ LoggerConfiguration loggerConfiguration post.PostConfigure(Options.DefaultName, loggerConfiguration); } } -} \ No newline at end of file +} + diff --git a/src/Serilog/LaunchPadLoggingOptions.cs b/src/Serilog/LaunchPadLoggingOptions.cs index eebe219d7..815c21873 100644 --- a/src/Serilog/LaunchPadLoggingOptions.cs +++ b/src/Serilog/LaunchPadLoggingOptions.cs @@ -3,6 +3,7 @@ namespace Rocket.Surgery.LaunchPad.Serilog; /// /// RocketSerilogOptions. /// +[PublicAPI] public class LaunchPadLoggingOptions { /// @@ -30,10 +31,10 @@ public class LaunchPadLoggingOptions /// /// Base option from the serilog package /// - public bool WriteToProviders { get; set; } = false; + public bool WriteToProviders { get; set; } /// /// Base option from the serilog package /// public bool PreserveStaticLogger { get; set; } -} \ No newline at end of file +} From 4f011d5909cb70ca602af7dfd9429ca46bf147c0 Mon Sep 17 00:00:00 2001 From: Rocket Understudy <33589210+rsg-bot@users.noreply.github.com> Date: Fri, 3 May 2024 11:34:51 -0400 Subject: [PATCH 2/2] Automatically linting code --- src/Hosting/Conventions/SerilogHostingConvention.cs | 3 +-- src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs | 5 +---- src/Serilog/LaunchPadLoggingOptions.cs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Hosting/Conventions/SerilogHostingConvention.cs b/src/Hosting/Conventions/SerilogHostingConvention.cs index 295f0a1fe..41dd0c752 100644 --- a/src/Hosting/Conventions/SerilogHostingConvention.cs +++ b/src/Hosting/Conventions/SerilogHostingConvention.cs @@ -3,7 +3,6 @@ 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; @@ -85,4 +84,4 @@ public void Register(IConventionContext context, IHostApplicationBuilder builder ) ); } -} +} \ No newline at end of file diff --git a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs index 35a44f63f..29b1badcf 100644 --- a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs +++ b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs @@ -1,9 +1,7 @@ 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; @@ -46,5 +44,4 @@ LoggerConfiguration loggerConfiguration post.PostConfigure(Options.DefaultName, loggerConfiguration); } } -} - +} \ No newline at end of file diff --git a/src/Serilog/LaunchPadLoggingOptions.cs b/src/Serilog/LaunchPadLoggingOptions.cs index 815c21873..c8f19bece 100644 --- a/src/Serilog/LaunchPadLoggingOptions.cs +++ b/src/Serilog/LaunchPadLoggingOptions.cs @@ -37,4 +37,4 @@ public class LaunchPadLoggingOptions /// Base option from the serilog package /// public bool PreserveStaticLogger { get; set; } -} +} \ No newline at end of file