diff --git a/src/api/tesseractmain.cpp b/src/api/tesseractmain.cpp index 8c332a9d..53f6df8e 100644 --- a/src/api/tesseractmain.cpp +++ b/src/api/tesseractmain.cpp @@ -25,6 +25,7 @@ #if defined(__USE_GNU) # include // for feenableexcept #endif +#include // for std::getenv #include #include @@ -619,10 +620,13 @@ int main(int argc, char **argv) { std::vector vars_vec; std::vector vars_values; -#if defined(NDEBUG) - // Disable debugging and informational messages from Leptonica. - setMsgSeverity(L_SEVERITY_ERROR); -#endif + if (std::getenv("LEPT_MSG_SEVERITY")) { + // Get Leptonica message level from environment variable. + setMsgSeverity(L_SEVERITY_EXTERNAL); + } else { + // Disable debugging and informational messages from Leptonica. + setMsgSeverity(L_SEVERITY_ERROR); + } #if defined(HAVE_TIFFIO_H) && defined(_WIN32) /* Show libtiff errors and warnings on console (not in GUI). */