summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2017-08-14 04:33:01 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2017-08-20 16:51:10 -0700
commit05cc6c966f4d340c42b89a74b63b1bd8fe22673d (patch)
tree87a9af559ea1f895556e2cf7c61ab7e2dd6a4b55 /README.md
parente0dd55e09074087f624443cd86439a854dc0cc18 (diff)
downloadspack-05cc6c966f4d340c42b89a74b63b1bd8fe22673d.tar.gz
spack-05cc6c966f4d340c42b89a74b63b1bd8fe22673d.tar.bz2
spack-05cc6c966f4d340c42b89a74b63b1bd8fe22673d.tar.xz
spack-05cc6c966f4d340c42b89a74b63b1bd8fe22673d.zip
Rework output redirection in Spack.
- Simplify interface to log_output. New interface requires only one context handler instead of two. Before: with log_output('logfile.txt') as log_redirection: with log_redirection: # do things ... output will be logged After: with log_output('logfile.txt'): # do things ... output will be logged If you also want the output to be echoed to ``stdout``, use the `echo` parameter:: with log_output('logfile.txt', echo=True): # do things ... output will be logged and printed out And, if you just want to echo *some* stuff from the parent, use ``force_echo``: with log_output('logfile.txt', echo=False) as logger: # do things ... output will be logged with logger.force_echo(): # things here will be echoed *and* logged A key difference between this and the previous implementation is that *everything* in the context handler is logged. Previously, things like `Executing phase 'configure'` would not be logged, only output to the screen, so understanding phases in the build log was difficult. - The implementation of `log_output()` is different in two major ways: 1. This implementation avoids race cases by using only one pipe (before we had a multiprocessing pipe and a unix pipe). The logger daemon stops naturally when the input stream is closed, which avoids a race in the previous implementation where we'd miss some lines of output because the parent would shut the daemon down before it was done with all output. 2. Instead of turning output redirection on and off, which prevented some things from being logged, this version uses control characters in the output stream to enable/disable forced echoing. We're using the time-honored xon and xoff codes, which tell the daemon to echo anything between them AND write it to the log. This is how `logger.force_echo()` works. - Fix places where output could get stuck in buffers by flushing more aggressively. This makes the output printed to the terminal the same as that which would be printed through a pipe to `cat` or to a file. Previously these could be weirdly different, and some output would be missing when redirecting Spack to a file or pipe. - Simplify input and color handling in both `build_environment.fork()` and `llnl.util.tty.log.log_output()`. Neither requires an input_stream parameter anymore; we assume stdin will be forwarded if possible. - remove `llnl.util.lang.duplicate_stream()` and remove associated monkey-patching in tests, as these aren't needed if you just check whether stdin is a tty and has a fileno attribute.
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions