Skip to content

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Oct 21, 2024

Add convenience group keyword to withlevel to do early filtering on groups

Export withlevel

Add convenience group keyword to withlevel to do early filtering on groups

Export withlevel
Comment on lines +92 to +95
For convenience, a `group` keyword argument can be passed which also
filters logging messages on the "group". By default, the group is the
file name of the log macro call site, but can be overridden by passing
the `_group` keyword argument to the logging macros.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not conviced thsi is better than just using

with_logger(EarlyFilteredLogger(x->x.group==:Foo) do
...
end

Maybe we should instead be adding a

filter_group_logger(group) = EarlyFilteredLogger(x->x.group==group)

if it really is too long

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really the convenience of having it bundled with the withlevel function. It's so onerous remembering the incantation to get the logger, set it to the new one, and then on top remember the LoggingExtras machinery to early filter. Bundling that all up into withlevel as the "one thing" I need to remember as a package dev is what makes this work really well.

Co-authored-by: Frames White <[email protected]>
@quinnj quinnj merged commit ff2644f into master Oct 23, 2024
8 checks passed
@quinnj quinnj deleted the jq-deprecate-verbosity branch October 23, 2024 21:16
@quinnj quinnj mentioned this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants