From 39d27b62457329d49ab02e43ba267b2574f2c9d6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 May 2023 16:45:40 +0530 Subject: [PATCH] Restore suppression of informational log messages from PoDoFo --- src/calibre/utils/podofo/podofo.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/calibre/utils/podofo/podofo.cpp b/src/calibre/utils/podofo/podofo.cpp index 4be6c410b9..ba9216b390 100644 --- a/src/calibre/utils/podofo/podofo.cpp +++ b/src/calibre/utils/podofo/podofo.cpp @@ -7,11 +7,20 @@ using namespace PoDoFo; #include "global.h" +#include PyObject *pdf::Error = NULL; static char podofo_doc[] = "Wrapper for the PoDoFo PDF library"; +static void +pdf_log_message(PdfLogSeverity logSeverity, const std::string_view& msg) { + if (logSeverity == PdfLogSeverity::Error || logSeverity == PdfLogSeverity::Warning) { + const char *level = logSeverity == PdfLogSeverity::Error ? "ERROR" : "WARNING"; + std::cerr << "PoDoFo" << level << ": " << msg << std::endl; + } +} + static int exec_module(PyObject *m) { if (PyType_Ready(&pdf::PDFDocType) < 0) return -1; @@ -23,6 +32,8 @@ exec_module(PyObject *m) { Py_INCREF(&pdf::PDFDocType); PyModule_AddObject(m, "PDFDoc", (PyObject *)&pdf::PDFDocType); + + PdfCommon::SetLogMessageCallback(pdf_log_message); return 0; }