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

Ability to print MuPDF errors to logging instead of stdout #3914

Open
jamesbraza opened this issue Oct 3, 2024 · 1 comment
Open

Ability to print MuPDF errors to logging instead of stdout #3914

jamesbraza opened this issue Oct 3, 2024 · 1 comment

Comments

@jamesbraza
Copy link

Is your feature request related to a problem? Please describe.

PyMuPDF==1.24.10 will occasionally print MuPDF errors to stdout.

The issue with print is:

  • Random stdout prints mess with CLI utilities like rich.Progress bars
  • Misses the opportunity for the benefits of Python logging (process global message formatting and/or filtering)

Describe the solution you'd like

Either:

  • PyMuPDF to expose a way for callers to "install" a logging.Logger instead of print
    • And message to support a "level" argument (e.g. error level, debug level, etc)
  • PyMuPDF to move to Python logging

Describe alternatives you've considered

None

Additional context

None

@julian-smith-artifex-com
Copy link
Collaborator

Latest PyMuPDF in git has new function pymupdf.use_python_logging() that allows PyMuPDF messages to be sent to Python's logging module. See: https://github.com/pymupdf/PyMuPDF/blob/main/src/__init__.py#L109

The function docstring describes how to use it, but we'll also add it to the main documentation soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants