silence warnings from code
|Status:||Closed||Start date:||29 Jan 2009|
When exiv2 is scanning the metadata of images, it often outputs warnings about minor problems on the console that makes it difficult to find messages about more acute problems. I know that one can run ./configure with -DSUPPRESS_WARNINGS to get it more quiet, but I reckon many users will have "apt-get installed" exiv2 rather than compiling it for themselves.
How about changing all the lines that now does e.g.
std:cerr << "Blah blah";
so that they instead call some central message-output method and also supply a severity level with the message.
Then, the code that calls exiv2 methods could call some method to set a threshold for which messages are passed thru to cerr.
#476, #614: Introduced class LogMsg for enhanced logging, migrated all existing warnings and error messages (not the exceptions) to use the new logic. Every log message now has a type (debug, info, warning, error). Applications can set a logging level to determine which messages are processed and supply a custom log message handler at runtime. (Based on a contribution by Simson Garfinkel.)
#2 Updated by Andreas Huggel about 8 years ago
- Category changed from basicio to design
- Status changed from New to Resolved
- Target version set to 0.21
- % Done changed from 0 to 100
Applications can now set the log level to determine which log messages they are interested in:
// Set the log level to only show errors (and suppress warnings, informational and debug messages) Exiv2::LogMsg::setLevel(Exiv2::LogMsg::error);
To suppress all log messages set the log level to
Exiv2::LogMsg::mute or set the log message handler to
0 (see #476).
For more details, see the new class
The SUPPRESS_WARNINGS mechanism still exists, in case there is a need to avoid compiling the log messaging calls in the library completely.