Use template-based logging and cached delegates #8457
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #6946
The T4 template for resource strings has been updated so that if the resource name starts with "Log", then we generate an EventDefinition using information from the comment section. This brings together the event ID, log-level, and a typed, cached delegate that can be called to log the event to an ILogger. It also contains a mechanism to generate the message for use when testing and when throwing warnings-as-errors. All the XxxLoggerExtensions class now use this mechanism.
As part of this, IInterceptingLogger was consolidated into IDiagnosticsLogger. There are no longer any Log methods here because logging is done through the definitions using the cached delegates.
A fallback mechanism--RawEventDefinition--can be used for messages with more than six parameters. There are only a handful of these, and they are for design-time scenarios and so don't need to be super fast.
Part of #218
Also, see #8456