Project

General

Profile

Bug #765

Debug messages of psdimages.cpp go to stdout instead of stderr

Added by Volker Grabsch over 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Category:
image format
Target version:
Start date:
07 Mar 2011
Due date:
% Done:

100%

Estimated time:

Description

The debug messages of psdimages.cpp are currently written to stdout instead of stderr. The attached patch fixes that.

History

#1

Updated by Volker Grabsch over 10 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 over 10 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 over 10 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.

#4

Updated by Volker Grabsch over 10 years ago

  • File deleted (exiv2-0.21.1_debug_psdimage.patch)
#5

Updated by Volker Grabsch over 10 years ago

That's a very nice convention. I'll follow that in future code, and I'll try to convert existing code if my time allows that.

On minor correction. The correct command to set the debug log level is:

LogMsg::setLevel(LogMsg::debug)
#6

Updated by Michael Ulbrich about 10 years ago

  • Status changed from New to Closed
#7

Updated by Andreas Huggel about 10 years ago

  • Status changed from Closed to Resolved

Thanks a lot for your work, Volker & Michael! I've updated this issue back to 'Resolved', following the usual process. It will get closed when it's released.

Andreas

#8

Updated by Andreas Huggel about 10 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF