I'm using Flask for an application that I need to build some recurrent reporting on .pdf.
But when it comes to build the .pdf and I add some images, when I use the "ImageReader" from reportlab it prints the following logs that I do not want it to print:
2024-02-16 11:31:44,180 STREAM b'IHDR' 16 13
2024-02-16 11:31:44,180 STREAM b'tEXt' 41 57
2024-02-16 11:31:44,181 STREAM b'pHYs' 110 9
2024-02-16 11:31:44,181 STREAM b'IDAT' 131 18719
This is the code:
buffer = BytesIO()
plt.savefig(buffer, format='png')
buffer.seek(0)
plot_image = ImageReader(buffer)
c.drawImage(plot_image, x, y, width=width, height=height)
The specific line where the logs appear is:
plot_image = ImageReader(buffer)
I've checked everywhere but couldn't find any working response on how to manage it.
Thank you very much for your time
I've already tried:
logging.getLogger('reportlab').setLevel(logging.CRITICAL)
logging.getLogger('pdfrw').setLevel(logging.CRITICAL)
And of course, i'm not looking for a general logging config such as:
logging.basicConfig(level=logging.CRITICAL)
It might be that the logging is not happening in reportlab
but in Pillow
, a dependency used for image handling. To confirm exactly where the logging is coming from, change your logging configuration to output the logger name in the log. Then you can do logging.getLogger(...).setLevel(logging,CRITICAL)
based on the name(s) you find. (For example, the name you find might be PIL
, or then again it could be something else.)