Turn on quiet mode when logfile specified

I'm not really sure why I originally had --logfile also log to stdout
in I202e1cb200bde17f6d7770cf1e2710bbf4cca64c, but it seem
counter-intuitive (indeed, I just tripped myself up thinking that in a
devstack job "--logfile" would put the logs into a separate file and
avoid the stdout logging, and I wrote it!).

Make it so specifying a --logfile puts dib into quiet mode for stdout.
Explicitly overriding DIB_QUIET will allow both if someone wants that.

Change-Id: I3279c9253eee1c9db69c958b87a0ce73efc0be9b
This commit is contained in:
Ian Wienand 2018-10-24 12:13:26 +11:00
parent dfd1e4fdaf
commit 86d5534352
2 changed files with 14 additions and 2 deletions

View File

@ -59,7 +59,7 @@ function show_options () {
echo " -x -- turn on tracing (use -x -x for very detailed tracing)." echo " -x -- turn on tracing (use -x -x for very detailed tracing)."
echo " -u -- uncompressed; do not compress the image - larger but faster" echo " -u -- uncompressed; do not compress the image - larger but faster"
echo " -c -- clear environment before starting work" echo " -c -- clear environment before starting work"
echo " --logfile -- save run output to given logfile" echo " --logfile -- save run output to given logfile (implies DIB_QUIET=1)"
echo " --checksum -- generate MD5 and SHA256 checksum files for the created image" echo " --checksum -- generate MD5 and SHA256 checksum files for the created image"
echo " --image-size size -- image size in GB for the created image" echo " --image-size size -- image size in GB for the created image"
echo " --image-cache directory -- location for cached images(default ~/.cache/image-create)" echo " --image-cache directory -- location for cached images(default ~/.cache/image-create)"
@ -94,7 +94,7 @@ function show_options () {
echo echo
echo " * ELEMENTS_PATH: specify external locations for the elements. As for \$PATH" echo " * ELEMENTS_PATH: specify external locations for the elements. As for \$PATH"
echo " * DIB_NO_TIMESTAMP: no timestamp prefix on output. Useful if capturing output" echo " * DIB_NO_TIMESTAMP: no timestamp prefix on output. Useful if capturing output"
echo " * DIB_QUIET: do not output log output to stdout. See --logfile" echo " * DIB_QUIET: 1=do not output log output to stdout; 0=always ouptut to stdout. See --logfile"
echo echo
echo "NOTE: At least one distribution root element must be specified." echo "NOTE: At least one distribution root element must be specified."
echo echo
@ -188,6 +188,12 @@ _TS_FLAG=""
if [[ "${DIB_NO_TIMESTAMP:-0}" -eq 1 ]]; then if [[ "${DIB_NO_TIMESTAMP:-0}" -eq 1 ]]; then
_TS_FLAG="--no-timestamp" _TS_FLAG="--no-timestamp"
fi fi
# A logfile with *no* DIB_QUIET specified implies we just want output
# to the logfile. Explicitly setting DIB_QUIET=0 will overide this
# and log both.
if [[ -n "${LOGFILE}" && -z "${DIB_QUIET}" ]]; then
DIB_QUIET=1
fi
_QUIET_FLAG="-v" _QUIET_FLAG="-v"
if [[ "${DIB_QUIET:-0}" -eq 1 ]]; then if [[ "${DIB_QUIET:-0}" -eq 1 ]]; then
_QUIET_FLAG="" _QUIET_FLAG=""

View File

@ -0,0 +1,6 @@
---
features:
- |
Setting ``--logfile`` will now imply ``DIB_QUIET=1`` (i.e. logs will
not appear on stdout). You can override this with an explicit
``DIB_QUIET=0`` if you want stdout and file logging.