-
Notifications
You must be signed in to change notification settings - Fork 794
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
Default ILogger implementations (netstandard 2.1) #1435
Conversation
along with: - build scripts actualization - added latest LTS .net framework / core targets - misc cleanup
|
||
[Theory] | ||
[MemberData(nameof(DefaultInterfaceMethods))] | ||
public void ILoggerDefaultMethodsShouldBeInSyncWithLogger(MethodInfo defaultInterfaceMethod) |
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.
Brilliant! Wouldn't have thought of this 😎
Looks awesome 👍 I'm wondering about the selection of non-default methods: public bool BindMessageTemplate(string messageTemplate, object[] propertyValues, out MessageTemplate parsedTemplate, out IEnumerable<LogEventProperty> boundProperties) => _inner.BindMessageTemplate(messageTemplate, propertyValues, out parsedTemplate, out boundProperties);
public bool BindProperty(string propertyName, object value, bool destructureObjects, out LogEventProperty property) => _inner.BindProperty(propertyName, value, destructureObjects, out property);
public ILogger ForContext(ILogEventEnricher enricher) => _inner.ForContext(enricher);
public ILogger ForContext(string propertyName, object value, bool destructureObjects = false) => _inner.ForContext(propertyName, value, destructureObjects);
public bool IsEnabled(LogEventLevel level) => _inner.IsEnabled(level);
public void Write(LogEvent logEvent) => _inner.Write(logEvent);
public void Write(LogEventLevel level, Exception exception, string messageTemplate, params object[] propertyValues) => _inner.Write(level, exception, messageTemplate, propertyValues); I think these are the methods that any wrapper or non-trivial For simple cases it seems like we could get away with
On the one hand, this would make it slightly harder to write a useful delegating logger/wrapper (the user would need to discover the requirement to forward methods other than I think the choices in the PR are the safer ones, just keen to know what you think about the trade-off. |
@nblumhardt totally makes sense 👍 I just realized that was the wrong reason, since I will adjust the PR with your suggestions and will add custom tests for the remaining methods |
Looks good! Think it would be interesting to get this out there. Bumped the minor version to 2.10. I missed the potential to call |
What issue does this PR address?
netstandard 2.1
tfmILogger
implemenation, addresses Default implementation for ILogger #861Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Other information:
Default
ILogger
implementation will make user story easier to implement the interface; with ability to further interface evolve. 72 overloads mirrorsLogger
methods: added test that checks the sync. For remaining methods added independent tests.netstandard2.1
allows adding further improvements utilizingSystem.Span<>
,System.Buffers
etc without introducing new dependencies.Additional cleanup, fixes, improvements, such as:
LoggerShouldNotReferenceToItsConfigurationAfterBeingCreated
test that is failed under Debug;