-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Log whether the localization resource is found or not #55897
base: main
Are you sure you want to change the base?
Conversation
@halter73 can you please review this? Thanks! |
} | ||
catch (MissingManifestResourceException) | ||
{ | ||
_missingManifestCache.TryAdd(cacheKey, null); | ||
|
||
Log.ResourceNotFound(_logger, name); |
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.
Should we provide a different log for a missing manifest vs a non-localized resource where the name == value
?
@DamianEdwards do you have an opinion on this?
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.
No real opinion, I'd defer to folks who've been using it for real to inform us to how useful that would be.
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.
IMHO we should log for both
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 agree we should log in both cases. I was asking if there should be a different log message for the two places this PR currently calls Log.ResourceNotFound
since the resource was not found for slightly different reasons, but I'm fine with using the same message whenever a resource is not found for any reason like the PR does currently.
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.
Or we could change the log level for missing manifest to trace
so in debug the missing resources will be logged which are useful in almost cases
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'd just leave them exactly the same for now. If we were going to change the log level, we'd want to give it a unique event id and log message. Changing the level of a log but nothing else would be confusing.
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.
Given that the SearchedLocation log exists, I wonder if we need a ResourceFound log. A lack of a ResourceNotFound log should imply that it was found. This would also mean less debug log noise for a fully localized application which seems like a good thing.
src/Localization/Localization/src/ResourceManagerStringLocalizer.cs
Outdated
Show resolved
Hide resolved
[LoggerMessage(2, LogLevel.Debug, $"The resource with key '{{Key}}' is not found.", EventName = "ResourceNotFound")] | ||
public static partial void ResourceNotFound(ILogger logger, string key); | ||
|
||
[LoggerMessage(3, LogLevel.Debug, $"The resource with key '{{Key}}' is found.", EventName = "ResourceFound")] |
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.
[LoggerMessage(3, LogLevel.Debug, $"The resource with key '{{Key}}' is found.", EventName = "ResourceFound")] |
Edit: I'd rather we remove this log altogether.
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.
So, you will the non found resources?
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'm not sure I understand your question, but I'm asking that we only add the "ResourceNotFound" log not the "ResourceFound" log.
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.
Forgot my above comment seems I miss some words during the writing :)
…er.cs Co-authored-by: Stephen Halter <halter73@gmail.com>
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
@halter73 what's the status PR? is there anything to add to merge it ASAP |
Yes. I would like to remove the "ResourceFound" logs and pass in the "Culture" parameter to |
src/Localization/Localization/src/ResourceManagerStringLocalizer.cs
Outdated
Show resolved
Hide resolved
src/Localization/Localization/src/ResourceManagerStringLocalizer.cs
Outdated
Show resolved
Hide resolved
src/Localization/Localization/src/ResourceManagerStringLocalizer.cs
Outdated
Show resolved
Hide resolved
@hishamco Do you think you can fix the build and test failures? We should also add a test case that checks the logs for |
Fixes #43109