-
Notifications
You must be signed in to change notification settings - Fork 130
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 a callback on the reader options to expose the log filter switches #366
Conversation
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.
LGTM 👍
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.
Looks good overall 👍 Just a minor concern around $ prefixing on callback invocation.
@@ -75,7 +75,8 @@ void ProcessFilterSwitchDeclarations() | |||
SetFilterSwitch(throwOnError: true); | |||
SubscribeToFilterExpressionChanges(); | |||
|
|||
_resolutionContext.AddFilterSwitch(switchName, filterSwitch); | |||
var referenceName = _resolutionContext.AddFilterSwitch(switchName, filterSwitch); | |||
_resolutionContext.ReaderOptions.OnFilterSwitchCreated?.Invoke(referenceName, filterSwitch); |
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 think the $ sign make sense only for a sink parameter in appsettings.json
to distinguish parameter value from variable reference:
"Filter": [
{
"Name": "ControlledBy",
"Args": {
"switch": "$filterSwitch"
}
}
]
And since #231 $
is optional in declaration section, leaving name as is should look more consistent with overrides.
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.
@0xced any thoughts on this one? (I'm working on merging everything through for a v7 shortly, would be great to get this PR in however this goes)
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 haven't forgotten about this. I will reply soon but I want to first experiment with a real world scenario to figure out what's best.
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 with you that there's no need to force the leading $
. So I addressed this in 7f5c27f.
Just like it was done for log level switches in serilog#352.
Just like it was done for log level switches in #352.