AlloSphere-Research-Group / AlloSystem

AlloSystem is a cross-platform suite of C++ components for building interactive multimedia tools and applications.
http://mat.ucsb.edu/allosphere/software.php
BSD 3-Clause "New" or "Revised" License
65 stars 22 forks source link

Error messages sent to stdout instead of stderr #12

Closed LancePutnam closed 12 years ago

LancePutnam commented 12 years ago

There are many places where error messages are sent to stdout like this:

printf("Error: Something went wrong...\n");

Errors should be piped to stderr, not stdout. The above should be replaced with this:

fprintf(stderr, "Error: Something went wrong...\n");

Note, that by default stderr prints to the console like stdout. The advantage of using stderr is that you can separate errors from normal output. See: http://jstorimer.com/2011/12/29/the-difference-between-stdout-and-stderr.html

matthewjameswright commented 12 years ago

I completely agree.

LancePutnam commented 12 years ago

I added two new macros AL_WARN and AL_WARN_ONCE to allocore/system/al_Printing.hpp to handle printing error/warning messages to stderr. Both are equivalent to fprintf(stderr, fmt, ...) taking a format string with variable args. The only difference is that AL_WARN_ONCE only prints the final formatted message once during the program life cycle. AL_WARN_ONCE should be used in favor of AL_WARN when reporting may take place inside of a real-time loop, such as the graphics loop, to prevent a continuous stream of error messages being printed out to the terminal that may mask preceding error messages.