Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tesseract: Disable Leptonica messages #543

Merged
merged 1 commit into from
Dec 7, 2016

Conversation

stweil
Copy link
Member

@stweil stweil commented Dec 7, 2016

Disable debugging and informational messages from Leptonica
for release builds.

Signed-off-by: Stefan Weil [email protected]

Disable debugging and informational messages from Leptonica
for release builds.

Signed-off-by: Stefan Weil <[email protected]>
@zdenop zdenop merged commit 94aebb1 into tesseract-ocr:master Dec 7, 2016
@stweil stweil deleted the leptonica branch December 7, 2016 20:58
@amitdo
Copy link
Collaborator

amitdo commented Dec 8, 2016

#522

stweil commented

... without those nagging messages, I'd never have had a look on that part of Leptonica.

DanBloomberg commented

Alternatively, for a bit more flexibility, you can define the environmental variable
#define LEPT_MSG_SEVERITY L_SEVERITY_WARNING
and use
setMsgSeverity(L_SEVERITY_EXTERNAL);

@amitdo
Copy link
Collaborator

amitdo commented Dec 8, 2016

I want the above option in the release build.
@stweil?

@stweil
Copy link
Member Author

stweil commented Dec 8, 2016

Using the environment variable would imply that you always get at least one message from Leptonica because the code which enables / disables warnings also writes messages. :-( That's why I decided against that feature for the moment.
Leptonica needs a modification which allows suppressing messages from setMsgSeverity, no matter whether the environment variable exists or not and no matter which message severity level is set.

@amitdo
Copy link
Collaborator

amitdo commented Dec 8, 2016

cc: @DanBloomberg

@DanBloomberg
Copy link

First, some more of the basics, for disabling at least all info and warning messages.

You can define the external env variable to L_SEVERITY_ERROR. That will disable warnings, which I believe makes sense for tesseract.

If you set this severity level at compile time, you guarantee that it can't be over-ridden at run-time.

If you want to go further and suppress all messages, including those from the ERROR_* macros (which are different from the informational L_* macros), define NO_CONSOLE_IO on the compile line (or use L_SEVERITY_NONE).

As for the suggestion that setMsgSeverity() tells you what it does, I can easily add a 2nd arg (debug) and only emit those messages when debug = TRUE. Stefan, is that what you want?

@DanBloomberg
Copy link

Better, I'll just comment out the comments, leaving the interface unchanged.

@stweil
Copy link
Member Author

stweil commented Dec 8, 2016

Yes, I'd prefer keeping the interface unchanged and disabling the messages (at least for arguments in the valid range).

@DanBloomberg
Copy link

this change is pushed to leptonica master on github

@DanBloomberg
Copy link

and modified to keep the warning(error) message but not the info(OK) messages

@stweil
Copy link
Member Author

stweil commented Dec 8, 2016

An unset environment variable should not result in a warning, as this is the normal case. With the latest Leptonica code this requires unnecessarily tricky code. I'd use L_INFO instead of L_WARNING.

@DanBloomberg
Copy link

I was thinking that if you try to set it to the external value, and that value is not set, it should issue a warning because the attempt failed. I am already commenting the L_INFOs out there, and I can comment the warning out as well.

@DanBloomberg
Copy link

All leptonica messages in setMsgSeverity() are now disabled, as requested.

@@ -388,6 +388,11 @@ int main(int argc, char** argv) {
static GenericVector<STRING> vars_vec;
static GenericVector<STRING> vars_values;

#if !defined(DEBUG)
Copy link
Contributor

@egorpugin egorpugin May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to #ifdef NDEBUG ? NDEBUG is more common than DEBUG.

@stweil
Copy link
Member Author

stweil commented May 8, 2017

Either DEBUG or NDEBUG is set by configure (depending on --enable-debug). It looks like cmake currently does not set DEBUG. Maybe that's the reason why api/baseapi.cpp also tests for _DEBUG (set my the MS compiler).

NDEBUG is a standard macro which changes the behavior of assert. That's also the reason why it is used rather often.

If we want to separately control standard features and Tesseract features, we need both macros. Otherwise we could stick to using NDEBUG.

Personally I prefer keeping both macros, but I think that removing DEBUG would also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants