Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sonologic
Copy link

Resolves: #2893

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

@sonologic
Copy link
Author

Note that linting is broken:

(venv) gmc@sunra:~/src/3rdparty/pelican/pelican$ invoke lint
usage: flake8 [options] file file ...
flake8: error: unrecognized arguments: --diff
(venv) gmc@sunra:~/src/3rdparty/pelican/pelican$ 

I used PyCharm though, and that will warn me when I try to violate PEP8 and a whole bunch of other rules.

@sonologic sonologic marked this pull request as draft March 13, 2023 09:43
@sonologic sonologic marked this pull request as ready for review March 13, 2023 09:45
@justinmayer
Copy link
Member

Note that linting is broken

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 python -m pip install "flake8~=3.9.0" and see if that rectifies that particular problem.

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.

@justinmayer justinmayer requested a review from avaris March 27, 2023 08:27
@sonologic
Copy link
Author

Note that linting is broken

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 python -m pip install "flake8~=3.9.0" and see if that rectifies that particular problem.

Yep, downgrading fixes it. Note that I used the requirements specifications in the requirements subdir. Specifically, requirements/style.pip specifies an unqualified flake8 install so it got the latest indeed.

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.

Cool, thanks in advance!

@justinmayer
Copy link
Member

Note that I used the requirements specifications in the requirements subdir. Specifically, requirements/style.pip specifies an unqualified flake8 install so it got the latest indeed.

Thanks for pointing that out. Fixed in master via 06c9e0f. 👍

Comment on lines 512 to 533
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")
Copy link
Member

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) :).

Comment on lines 138 to 142
(logging.WARN, 'TAG_SAVE_AS is set to False'),
('string', logging.WARN, 'Empty theme folder. Using `basic` theme.'),
Copy link
Member

@avaris avaris Apr 20, 2023

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.

@justinmayer
Copy link
Member

@sonologic: I updated your PR branch on latest master, and as expected, the linter problems have been resolved. 🌟

Would you be so kind as to address the feedback from @avaris above so we can get your contribution merged?

@sonologic
Copy link
Author

@sonologic: I updated your PR branch on latest master, and as expected, the linter problems have been resolved. 🌟

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.

@justinmayer
Copy link
Member

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. ✨

@sonologic
Copy link
Author

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. ✨

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.

@justinmayer
Copy link
Member

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.

@avaris
Copy link
Member

avaris commented Oct 30, 2023

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 :(.

@sonologic
Copy link
Author

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.

@sonologic
Copy link
Author

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.

@sonologic
Copy link
Author

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 :)

@justinmayer
Copy link
Member

These conflicts are the result of merging #3231, which applies ruff format . to the entire code base. We held off as long as we could, knowing it would cause some merge conflicts for the few PRs in the queue.

@avaris
Copy link
Member

avaris commented Oct 30, 2023

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.

No worries, I can make changes from here. If possible I can handle fixing conflicts.

@MinchinWeb
Copy link
Contributor

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...

@sonologic
Copy link
Author

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.

No worries, I can make changes from here. If possible I can handle fixing conflicts.

Curious how this went. Did the release go out? Are the refactorings in? Should I give this one another go?

@avaris
Copy link
Member

avaris commented Dec 6, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Ability to filter log messages by regular expression
4 participants