From 4d6e1aa1f67fd7c9a4eb4785a15edbd2e633032f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 26 Aug 2012 14:18:19 +0530 Subject: [PATCH] PoDoFo, do not print out informational messages --- src/calibre/utils/podofo/podofo.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/calibre/utils/podofo/podofo.cpp b/src/calibre/utils/podofo/podofo.cpp index b79ca8cfe3..eefe182cec 100644 --- a/src/calibre/utils/podofo/podofo.cpp +++ b/src/calibre/utils/podofo/podofo.cpp @@ -14,6 +14,29 @@ static PyMethodDef podofo_methods[] = { {NULL} /* Sentinel */ }; +class PyLogMessage : public PdfError::LogMessageCallback { + + public: + ~PyLogMessage() {} + + void LogMessage(ELogSeverity severity, const char* prefix, const char* msg, va_list & args ) { + if (severity > eLogSeverity_Warning) return; + if (prefix) + fprintf(stderr, "%s", prefix); + + vfprintf(stderr, msg, args); + } + + void LogMessage(ELogSeverity severity, const wchar_t* prefix, const wchar_t* msg, va_list & args ) { + if (severity > eLogSeverity_Warning) return; + if (prefix) + fwprintf(stderr, prefix); + + vfwprintf(stderr, msg, args); + } +}; + +PyLogMessage log_message; PyMODINIT_FUNC initpodofo(void) @@ -26,6 +49,9 @@ initpodofo(void) pdf::Error = PyErr_NewException((char*)"podofo.Error", NULL, NULL); if (pdf::Error == NULL) return; + PdfError::SetLogMessageCallback((PdfError::LogMessageCallback*)&log_message); + + PdfError::EnableDebug(false); m = Py_InitModule3("podofo", podofo_methods, "Wrapper for the PoDoFo PDF library");