Debug messages of psdimages.cpp go to stdout instead of stderr
|Status:||Closed||Start date:||07 Mar 2011|
|Assignee:||Andreas Huggel||% Done:|
The debug messages of psdimages.cpp are currently written to stdout instead of stderr. The attached patch fixes that.
#1 Updated by Volker Grabsch almost 8 years ago
I'm not sure whether this was really a bug. Some of the src/*image.cpp files prefer stdout and others prefer stderr for DEBUG messages. Some even mix them.
Is there any convention / best practice about this?
Maybe some central kind of "std::istream &Exiv2::debug;" could provide more clarity here?
#2 Updated by Volker Grabsch almost 8 years ago
Sorry for the typo. I was of course thinking of an "ostream" instead of "istream", something like this:
std::ostream &Exiv2::debug = std::cerr;
This would even allow to use a std::ostrstream to collect all debug messages to show them in a GUI rather than having them always written to stdout or stderr.
#3 Updated by Andreas Huggel almost 8 years ago
Debug output is not really standardized yet, but spelling out a convention is easy, now that we have LogMsg:
Debug output should use the
EXV_DEBUG macro instead of any std output stream and be enclosed in
#ifdef DEBUG blocks (similar to how warnings and errors are now handled). For example:
#ifdef DEBUG EXV_DEBUG << std::hex << "resourceId: " << id << std::dec << " length: " << size << "\n"; #endif
The application then just has to call
LogMsg::setLevel(debug) and can optionally set its own log message handler to do with the output whatever it wants.
Coming up with a guideline for the kind of debug output that should be in the code is more difficult. The way I use debug output myself usually is to find out what's going on in some very specific situation. This kind of debug output is generally not interesting in a more general context.