ISSUE-1585 | Surface fontTools logs for easier investigation
Work-in-progress.
Taking the feedback from the following 2 issues into this PR:
- https://github.com/Kozea/WeasyPrint/issues/1585
- https://github.com/fonttools/fonttools/issues/3538
After thinking about the best way to solve this issue, here’s what seems to be the best solution for me.
The code needed to capture logs is already in WeasyPrint: it’s used for tests, to check that we get no warning or the intended warning messages, depending on the test.
https://github.com/Kozea/WeasyPrint/blob/6e93e95354dc968180b09986fb23c3e35c8cbfe1/tests/testing_utils.py#L73-L100
What we could do is:
- Move
CallbackHandlerandcapture_logstologger.py. - Add a parameter to
capture_logsto define the logger we want to capture. Its default value would be'weasyprint'to keep the current default behaviour. - Use
with capture_logs('fontTools') as logs:around the call tosubsetter.subset()and display the logs thanks toLOGGER.warning(), just as you did in your PR.
What do you think of this solution?
As the code has changed a bit in main, you should probably create a new branch from main, create a new commit and push force to your branch.
I’ve fixed the problem in 61852c4. Thanks a lot for your investigation and for your proposal. 💜