levigo / jbig2-imageio

A Java ImageIO plugin for the JBIG2 bi-level image format
Apache License 2.0
31 stars 19 forks source link

Reduce logging level when globals are not set. #3

Closed dbdr closed 9 years ago

dbdr commented 9 years ago

jbig2-imageio currently logs a message at level info when globals are not set. The issue with this is that it's not necessarily an issue not to set them, in particular if they are passed as part of the image stream, but the info level is printed by default, leading to undesirable noise. When the globals are actually missing there will be another log entry: "SEVERE: No global segment added so far.". Therefore this pull request reduces the log level for this message.

ghost commented 9 years ago

The info is important for embedded JBIG2-compressed images. As you mentioned, it's not necessarily an issue in standalone files. As the main use-case for the plugin is the JBIG2Decode filtering in PDFs it is important. In the most logging systems you can set filters on classes, packages etc. My suggestion is to configure your logging system to ignore INFO messages at a reasonable scope.

dbdr commented 9 years ago

Thanks for your answer, and sorry if I wasn't clear: the issue is not just for standalone images. For instance, the pdfbox library handles globals by concatenating them before the image content, so they work fine but you still get the INFO log entries even though it's irrelevant in that case. Configuring the logging system is fine if you are the end user, but I'm not sure it's a good idea when writing a library (for instance, the end user might replace the configuration with their own), and it's unreasonable to ask all end users to hide specific messages.

I agree it's important to log missing globals, but that is already done anyway when they are actually found to be missing. I just added a second commit to give more information in that log entry. Does this help?

jstray commented 8 years ago

I don't find this a helpful log message -- is there actually something different PDFBox could do to prevent my log from being spammed while processing PDFs with embedded JBIGs? They say no, that this is really a bug in jbig2-imageio: https://issues.apache.org/jira/browse/PDFBOX-2594

theMattCode commented 8 years ago

This is simply an INFO-level message. Most logging frameworks support filtering to suppress special messages.

theMattCode commented 8 years ago

By the way, the pull-request was accepted and merged. Any problems with the DEBUG-level anyway?

jstray commented 8 years ago

All I know is that we now have two libraries who are each saying it's the other person's fault.

ghost commented 8 years ago

Is there anything I miss in this discussion?

The pull-request was merged. The log level is on debug instead of info. In turn, end-user problems should be fixed by that.