Restore suppression of informational log messages from PoDoFo

This commit is contained in:
Kovid Goyal 2023-05-11 16:45:40 +05:30
parent bea63dc6c4
commit 39d27b6245
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,11 +7,20 @@
using namespace PoDoFo;
#include "global.h"
#include <iostream>
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;
}