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

Extract / Make log filtering configurable. #199

Open
Carreau opened this issue Feb 8, 2023 · 0 comments
Open

Extract / Make log filtering configurable. #199

Carreau opened this issue Feb 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Carreau
Copy link
Member

Carreau commented Feb 8, 2023

Currently matplotlib generate logs while building the docs that pollute the output.

We need to find a way to silence and/or capture those.

Here is the current code:

papyri/papyri/gen.py

Lines 985 to 1007 in 1740a4a

class MF(logging.Filter):
"""
This is a matplotlib filter to temporarily silence a bunch of warning
messages that are emitted if font are not found
"""
def filter(self, record):
if "Generic family" in record.msg:
return 0
if "found for the serif fontfamily" in record.msg:
return 0
if "not found. Falling back to" in record.msg:
return 0
if "Substituting symbol" in record.msg:
return 0
return 1
mlog = logging.getLogger("matplotlib.font_manager")
mlog.addFilter(MF("serif"))
mplog = logging.getLogger("matplotlib.mathtext")
mplog.addFilter(MF("serif"))

I'm thinking it would be great to find a way to filter from the configuration that looks like pytest filterwarnings, with some customization as of course we dont' have a warning class but a log level...

[tool.pytest.ini_options]
filterwarnings = [
    "ignore::INFO",
    # note the use of single quote below to denote "raw" strings in TOML
    'error:function ham\(\) is deprecated:DEBUG',
]

If running example could also capture the logs, and insert them as output that would be a great addition.

@melissawm melissawm added the enhancement New feature or request label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants