Skip to content

implicitly convert regular BusLogger to SerilogLoggingAdapter when ForContext is called #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented May 29, 2024

Changes

close #284 - requires akkadotnet/akka.net#7210 to be merged and Akka.NET v1.5.22 to get shipped.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detailed my changes

@@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{489D8D37
build.sh = build.sh
src\Directory.Build.props = src\Directory.Build.props
src\Directory.Packages.props = src\Directory.Packages.props
NuGet.config = NuGet.config
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it easier to edit NuGet.config from within the IDE

/// Used to test that https://github.com/akkadotnet/Akka.Logger.Serilog/issues/284 is fixed
/// </summary>
[Fact]
public void ShouldLogMessageWithContextPropertyDefaultLogger()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests that start with a default BugLogger and ensure that the output matches what a user would see with the SerilogLoggingAdapter under the same conditions.

@@ -15,7 +15,18 @@ public static class SerilogLoggingAdapterExtensions
/// <param name="destructureObjects">If true, the value will be serialized as a structured object if possible; if false, the object will be recorded as a scalar or simple array.</param>
public static ILoggingAdapter ForContext(this ILoggingAdapter adapter, string propertyName, object value, bool destructureObjects = false)
{
return adapter is not SerilogLoggingAdapter customAdapter ? adapter : customAdapter.SetContextProperty(propertyName, value, destructureObjects);
if(adapter is SerilogLoggingAdapter customAdapter)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real fix

@@ -12,7 +12,7 @@
<LangVersion>10</LangVersion>
</PropertyGroup>
<PropertyGroup>
<AkkaVersion>1.5.14</AkkaVersion>
<AkkaVersion>1.5.22-beta1</AkkaVersion>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used a local beta that I created - will require Akka.NET v1.5.22 once that ships.

@Aaronontheweb Aaronontheweb marked this pull request as ready for review June 4, 2024 19:32
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) June 4, 2024 19:41
@Aaronontheweb Aaronontheweb merged commit 80152d9 into akkadotnet:dev Jun 4, 2024
1 check passed
@Aaronontheweb Aaronontheweb deleted the fromcontext branch June 12, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically convert ILoggingAdapter into SerilogLoggingAdapter when FromContext is called.
1 participant