redo-log: fix stdout vs stderr; don't recapture if .do script redirects stderr.

redo-log should log to stdout, because when you ask for the specific
logs from a run, the logs are the output you requested.  redo-log's
stderr should be about any errors retrieving that output.

On the other hand, when you run redo, the logs are literally the stderr
of the build steps, which are incidental to the main job (building
things).  So that should be send to stderr.  Previously, we were
sending to stderr when --no-log, but stdout when --log, which is
totally wrong.

Also, adding redo-log had the unexpected result that if a .do script
redirected the stderr of a sub-redo or redo-ifchange to a file or pipe,
the output would be eaten by redo-log instead of the intended output.
So a test runner like this:

	self.test:
		redo self.runtest 2>&1 | grep ERROR

would not work; the self.runtest output would be sent to redo's log
buffer (and from there, probably printed to the toplevel redo's stderr)
rather than passed along to grep.
This commit is contained in:
Avery Pennarun 2018-11-19 16:27:41 -05:00
commit 7165b342f5
2 changed files with 23 additions and 4 deletions

View file

@ -17,6 +17,7 @@ VERBOSE = os.environ.get('REDO_VERBOSE', '') and 1 or 0
XTRACE = os.environ.get('REDO_XTRACE', '') and 1 or 0
KEEP_GOING = os.environ.get('REDO_KEEP_GOING', '') and 1 or 0
LOG = atoi(os.environ.get('REDO_LOG', '1')) # defaults on
LOG_INODE = os.environ.get('REDO_LOG_INODE', '')
COLOR = atoi(os.environ.get('REDO_COLOR', '1')) # defaults on
# subprocesses mustn't pretty-print if a parent is running redo-log
PRETTY = (not LOG) and atoi(os.environ.get('REDO_PRETTY', '1'))