maxpmaxp / pdfreader

Python API for PDF documents
MIT License
113 stars 26 forks source link

Supressing logging warning messages #105

Closed pfuntner closed 4 months ago

pfuntner commented 1 year ago

I have a use case where I was using pdfreader 0.1.12 and was seeing many warnings like the following:

2023-02-19 08:14:26,170 WARNING /home/mrbruno/.local/lib/python3.8/site-packages/pdfreader/codecs/decoder.py:187 Can't build Decoder for font {'Type': 'Font', 'Subtype': 'Type1', 'BaseFont': 'MyriadPro-Regular', 'FirstChar': 32, 'LastChar': 121, 'Widths': [212, 0, 0, 0, 0, 0, 0, 0, 284, 284, 0, 0, 207, 307, 207, 343, 513, 513, 513, 513, 513, 513, 513, 513, 513, 513, 207, 0, 0, 0, 0, 0, 0, 612, 0, 580, 666, 492, 0, 646, 652, 239, 0, 542, 472, 804, 658, 689, 532, 0, 538, 493, 497, 0, 558, 846, 0, 541, 0, 0, 0, 0, 0, 0, 0, 482, 569, 448, 564, 501, 292, 559, 555, 234, 0, 0, 236, 834, 555, 549, 569, 0, 327, 396, 331, 551, 481, 736, 0, 471], 'FontDescriptor': <IndirectReference:n=77,g=0>}. Trying to use default.

For my purposes, I just want the document text and don't care that a decoder can't be built. The class works fine otherwise and I can pull out the text just like I want but the warnings are very annoying.

I took a shot at supplying a logging level via environment variable with a default in my a branch of my fork that seems to help but it's not ready for a pull request yet:

I invite feedback on any of the issues.

maxpmaxp commented 1 year ago

@pfuntner feel free to submit a pr if you have a chance. if not, I'll try to dedicate some time in Apr.

maxpmaxp commented 4 months ago

Reduced the logging noise by setting debug instead of warning almost everywhere.