-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Allow usage of regex in LOG_FILTER
setting
#3108
base: main
Are you sure you want to change the base?
Conversation
Note that linting is broken:
I used PyCharm though, and that will warn me when I try to violate PEP8 and a whole bunch of other rules. |
9fe55f2
to
38701d0
Compare
I don't get the same result. I believe that is because you are using a newer version of Flake8, whereas for now we have pinned that linter dependency to version 3.9.*. Please try Regarding the tests, they are currently failing due to changes in Pelican's Python package dependency versions, which has nothing to do with the enhancements in this pull request. I submitted PR #3112 to address this. Once that PR has been merged, this PR can be rebased in order to ensure the changes here pass all tests. |
Yep, downgrading fixes it. Note that I used the requirements specifications in the
Cool, thanks in advance! |
Thanks for pointing that out. Fixed in |
pelican/settings.py
Outdated
for item in log_filter: | ||
if len(item) == 2: # old-style string or template | ||
LimitFilter.ignore.update({item}) | ||
elif len(item) == 3: # new-style string/template or regexp | ||
if item[0] == "string": | ||
LimitFilter.ignore.update({(item[1:])}) | ||
elif item[0] == "regex": | ||
regex = re.compile(item[2]) | ||
LimitFilter.ignore_regexp.update({(item[1], regex)}) | ||
else: | ||
raise ValueError(f"Invalid LOG_FILTER type '{item[0]}'") | ||
else: | ||
raise ValueError(f"Invalid item '{str(item)}' in LOG_FILTER") |
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 it makes more sense to move this logic to LimitFilter
instead, say a @classmethod
named add_ignore_rule
.
Also, LimitFilter.ignore.update({item})
is a long way of writing LimitFilter.ignore.add(item)
:).
docs/settings.rst
Outdated
(logging.WARN, 'TAG_SAVE_AS is set to False'), | ||
('string', logging.WARN, 'Empty theme folder. Using `basic` theme.'), |
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.
If I understand correctly, 2 item one and the one starting with "string"
are essentially same thing. And I'm guessing, "string"
is added to make it consistent(?) with "regex"
. This duplication is a bit redundant. I'd much rather have the "2 item" version deprecated but internally still supported by auto-changing it to "3 item string" version with a warning issued.
@sonologic: I updated your PR branch on latest Would you be so kind as to address the feedback from @avaris above so we can get your contribution merged? |
I'm sorry, I've really neglected this PR, life kinda got in the way. Let me carve out some time to continue work on this so we can get it merged. I'll address the comments indeed. Apologies for the delay. |
That would be great, Koen. When do you think you might be able to find time to address that feedback? We are planning to release Pelican 4.9 tomorrow or Wednesday, and it would be wonderful to also include your contribution. ✨ |
ae97fb9
to
56a9ff1
Compare
56a9ff1
to
284ea41
Compare
No pressure then :) I think I have addressed all the comments just now. Let's see what CI thinks of it, but imho it's good to go now. |
Thanks for jumping on this so quickly! Looks like all CI checks are green. I believe @avaris will take one last look to make sure everything looks okay, as soon as he has a moment. |
I am looking at #3038 at the same time and that refactors how logging is done in a major way. That one and this are conflicting with each other currently. I'd prefer to merge that first and handle this one later adopting the code. So, I wish I had seen the latest comments earlier. That might've saved you some (maybe) unnecessary work at this time, sorry @sonologic :(. |
Well, it was only an hour, but I don't think I can make more time available on such short notice, so this feature will have to wait for a future release then. |
Did you already merge it? The conflicts don't seem all that extensive, I might fit in a few minutes to look at them tomorrow, depending on how crazy things get at the day job. |
Just looked at the MR. Seems indeed like this PR can be thrown in the bin, and I need to redo it for the new thing. That for sure is not going to happen this week. So I guess we can close this PR without merging, and I'll see when I can redo the work. Probably will be a few months again :) |
These conflicts are the result of merging #3231, which applies |
No worries, I can make changes from here. If possible I can handle fixing conflicts. |
Just an encouragement... I would use this feature if it was in Pelican! My particular use-case is I'm building a Reader using the Markdown-IT library, but if you set the log level to debug, it logs every token processing, which quickly amounts to hundreds of lines! This would make it simple to all go away... |
Curious how this went. Did the release go out? Are the refactorings in? Should I give this one another go? |
4.9 is released, but without #3038. It wasn't ready. I'm still waiting some activity on that. So... I can't really give a timeline. I can ping here when things move forward and this PR is ready for more work, if you would like to resolve that as well. But my offer stands, I'd be happy to lend a hand and handle that part if it won't be convenient for you. |
Resolves: #2893