Skip to content
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

Add EnrichDiagnosticContextAsync as async addition #345

Open
hbunjes opened this issue Sep 18, 2023 · 1 comment
Open

Add EnrichDiagnosticContextAsync as async addition #345

hbunjes opened this issue Sep 18, 2023 · 1 comment

Comments

@hbunjes
Copy link

hbunjes commented Sep 18, 2023

Is your feature request related to a problem? Please describe.
I want to enrich the http logging with Serilog by parts of the request body. Therefore, I read from the request body which must be done async. However, if a set EnrichDiagnosticContext to an async method like the following I get the VSTHRD101 warning:

options.EnrichDiagnosticContext = async (context, httpContext) =>
    {
        await LogHelper.EnrichFromRequestAsync(context, httpContext);
    };

Describe the solution you'd like
In addition to the Action<IDiagnosticContext, HttpContext>? EnrichDiagnosticContext, there should be a Func<IDiagnosticContext, HttpContext, Task>? EnrichDiagnosticContextAsync that can be called asynchronously and returns just a Task.

@hbunjes
Copy link
Author

hbunjes commented Sep 20, 2023

I've added a PR to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant