cbernardo / libIGES

Implementation of the IGESv5.3 specification
http://cbernardo.github.io/libIGES
GNU Lesser General Public License v2.1
58 stars 18 forks source link

Libraries should never write to stdout, write to stderr instead #22

Closed hrobeers closed 3 years ago

hrobeers commented 3 years ago

stdout is reserved for application output, libraries writing to it mess up normal behaviour.

I replaced all std::cout references with std::cerr in this PR. Even better would be to have a way to specify the desired std::ostream (defaulting to std::cerr).

cbernardo commented 3 years ago

Thanks; I'll push the patch. In retrospect I shouldn't be printing anything at all from the library but I haven't seen any good cross-platform mechanism for logging such information.

hrobeers commented 3 years ago

Yeah there isn't a unified system.

I found stderr the safer choice and even better is to have an std::ostream function arg that defaults to stderr but can be overridden by the user with any other std::ostream.

stdout can only be used for real program output. An option to have libIGES write IGES files to stdout would be really nice as well.