From 86d5534352141efb7ca49d41b561c87e9dc0e6bb Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 24 Oct 2018 12:13:26 +1100 Subject: [PATCH] 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 --- diskimage_builder/lib/disk-image-create | 10 ++++++++-- releasenotes/notes/logfile-quiet-b18f2de4059eecfd.yaml | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/logfile-quiet-b18f2de4059eecfd.yaml diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create index 8400ae709..50fe83db6 100644 --- a/diskimage_builder/lib/disk-image-create +++ b/diskimage_builder/lib/disk-image-create @@ -59,7 +59,7 @@ function show_options () { echo " -x -- turn on tracing (use -x -x for very detailed tracing)." echo " -u -- uncompressed; do not compress the image - larger but faster" 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 " --image-size size -- image size in GB for the created image" echo " --image-cache directory -- location for cached images(default ~/.cache/image-create)" @@ -94,7 +94,7 @@ function show_options () { echo 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_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 "NOTE: At least one distribution root element must be specified." echo @@ -188,6 +188,12 @@ _TS_FLAG="" if [[ "${DIB_NO_TIMESTAMP:-0}" -eq 1 ]]; then _TS_FLAG="--no-timestamp" 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" if [[ "${DIB_QUIET:-0}" -eq 1 ]]; then _QUIET_FLAG="" diff --git a/releasenotes/notes/logfile-quiet-b18f2de4059eecfd.yaml b/releasenotes/notes/logfile-quiet-b18f2de4059eecfd.yaml new file mode 100644 index 000000000..0819b0b76 --- /dev/null +++ b/releasenotes/notes/logfile-quiet-b18f2de4059eecfd.yaml @@ -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.