I/O: use different streams for produced SMT text and progress messages
Opened this issue · 2 comments
(From David Déharbe)
On UNIX-like systems, smtpp produces output on the same I/O connection for SMT and progress messages (log/warning/etc).
I think it would simplify the integration of smtpp in workflows to have such information sent to stdout and stderr, respectively.
From: http://en.wikipedia.org/wiki/Standard_streams
Standard error is another output stream typically used by programs to output error messages or diagnostics. It is a stream independent of standard output and can be redirected separately. This solves the semipredicate problem, allowing output and errors to be distinguished, and is analogous to a function returning a pair of values – see Semipredicate problem: Multivalued return. The usual destination is the text terminal which started the program to provide the best chance of being seen even if standard output is redirected (so not readily observed). For example, output of a program in a pipeline is redirected to input of the next program, but errors from each program still go directly to the text terminal.
It is acceptable—and normal—for standard output and standard error to be directed to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. (For example, a common situation is when the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream's buffer is not yet full.)
The file descriptor for standard error is defined by POSIX as 2 (two); the <unistd.h> header file provides the symbol STDERR_FILENO;[2] the corresponding <stdio.h> variable is FILE* stderr. The C++ standard header provides two variables associated with this stream: std::cerr and std::clog, the former being unbuffered and the latter using the same buffering mechanism as all other C++ streams.
(From David Déharbe)
Sorry to be insisting on this point but I feel that, for a pre-processor, the most UNIXy default settings are:
- to have pretty-printing set by default, to stdout.
- to never print success (smtpp not being a solver)
- remaining output should be sent to stderr. This is the default behaviour in Python, and historically the purpose of stderr.
For reference, this part of the Python doc talks about the stderr behavior:
By default, no destination is set for any logging messages. You can specify a destination
(such as console or file) by using basicConfig() as in the tutorial examples. If you call the
functions debug(), info(), warning(), error() and critical(), they will check to see if
no destination is set; and if one is not set, they will set a destination of the console (sys.stderr)
and a default format for the displayed message before delegating to the root logger to do the
actual message output.