Skip to content

Add log event property enricher support #229

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
May 12, 2023

Conversation

Arkatufus
Copy link
Contributor

Add enricher functionality, ILogEventEnricher enrichers can be appended at the end of the log message arguments like so:

Context.GetLogger().Info("Actor received {ID}", o, new PropertyEnricher(
    "custom-property", 
    new
    {
        name = "Custom", 
        data = counter
    }));

Copy link
Member

@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.

Need to add a unit test for this I think

@@ -51,6 +51,11 @@ private static object[] GetArgs(object message)
logger = logMessage.Enrichers.OfType<PropertyEnricher>().Aggregate(logger, (current, enricher) => current.ForContext(enricher));
}

if (logEvent.Message is LogMessage message)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM but I'd like to see a unit test added to cover this

Copy link
Member

@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.

Need to add a unit test for this I think

@Arkatufus
Copy link
Contributor Author

Added unit test for both default and serilog message formatter

Copy link
Member

@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.

LGTM

@Aaronontheweb Aaronontheweb merged commit 8255627 into akkadotnet:dev May 12, 2023
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.

2 participants