-
Notifications
You must be signed in to change notification settings - Fork 715
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
subscriber: add Targets::targets
method to iterate directives
#1574
Merged
Commits on Sep 17, 2021
-
subscriber: implement
IntoIterator
for&Targets
There's currently no way to get the registered directives from a `Targets` instance, which is a barrier to some use-cases such as combining user-supplied directives with application-supplied defaults. This commit implements `IntoIterator` for `&Targets`. The returned iterator will yield `(&str, LevelFilter)` pairs, on for each directive (excluding the default level, whose `target` is `None`). Additionally, an `iter` method has been added to `Targets` as a convenience for obtaining an iterator for method chaining. Items are yielded as per the underlying `DirectiveSet::iter`, which would yield items in specifity order (as constructed by `DirectiveSet::add`). However, the order has been left explicitly undefined in the documentation for `Targets::targets` on the basis that this is an implementation detail that may change. In order to namespace the `Iter` type nicely, the `tracing_subscriber::filter::targets` module has been made public, along with some nominal documentation. The `filter` module continues to re-export the `Targets` type so this is not a breaking change.
Configuration menu - View commit details
-
Copy full SHA for 2abb38c - Browse repository at this point
Copy the full SHA 2abb38cView commit details -
subscriber: implement
IntoIterator
forTargets
This adds an owning iterator implementation for `Targets`. The returned `IntoIter` type is hosted in `filter::targets` alongside the existing `Iter` type. Due to the underlying directive storage being determined based on features, `IntoIterator` has also been implemented on the internal `DirectiveSet` type to keep the feature handling within that module.
Configuration menu - View commit details
-
Copy full SHA for 992ee96 - Browse repository at this point
Copy the full SHA 992ee96View commit details
Commits on Sep 18, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 0d589ae - Browse repository at this point
Copy the full SHA 0d589aeView commit details -
subscriber: Add
targets
iterator constructorsThis moves the logic of creating the inner iterator into a constructor function on the iterators themselves. This brings the type definition and implementation closer together. The implementation has been changed to use closures, since they don't capture and can be converted to `fn()`. This avoids repeating the signature.
Configuration menu - View commit details
-
Copy full SHA for 6e80a9f - Browse repository at this point
Copy the full SHA 6e80a9fView commit details -
Configuration menu - View commit details
-
Copy full SHA for d8cdc44 - Browse repository at this point
Copy the full SHA d8cdc44View commit details -
subscriber: import
FilterMap
intargets
This cuts down some noise, since we use it twice.
Configuration menu - View commit details
-
Copy full SHA for 59a816e - Browse repository at this point
Copy the full SHA 59a816eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 98153a1 - Browse repository at this point
Copy the full SHA 98153a1View commit details
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.