-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add LoggerMessageAttribute constructor's overloads #87738
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 LoggerMessageAttribute constructor's overloads #87738
Conversation
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
Tagging subscribers to this area: @dotnet/area-extensions-logging Issue DetailsFixes #87254
|
|
Note that this change might require an update to the dotnet/runtime logging generator (distinct from the dotnet/extensions extended generator) |
What do you mean by |
Duh. Never mind, I spaced out... |
| eventId = items[0].IsNull ? -1 : (int)GetItem(items[0]); | ||
| level = items[1].IsNull ? null : (int?)GetItem(items[1]); | ||
| message = items[2].IsNull ? string.Empty : (string)GetItem(items[2]); | ||
| switch (items.Length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we correctly handle, e.g.
[LoggerMessage(level: LogLevel.Warning, message: "custom message", eventId: 0)]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed this work with and without the new changes.
src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Parser.cs
Show resolved
Hide resolved
|
So @tarekgh, we should make sure both generators do this the same way. So please let me know what hash function you end up using on the event name in order to produce the event id, and I'll use the same thing on my end. |
Fixes #87254