Skip to content

Commit 21b4554

Browse files
committed
Add log level environment variable
Add a "quiet" mode for non-CI usage when we want things to be quick and quiet.
1 parent 27b9138 commit 21b4554

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

ci/run_task.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
# Shellcheck can't search dynamic paths
66
# shellcheck source=/dev/null
77

8-
set -euox pipefail
8+
set -euo pipefail
99

1010
REPO_DIR=$(git rev-parse --show-toplevel)
1111

12-
# Make all cargo invocations verbose.
13-
export CARGO_TERM_VERBOSE=true
14-
15-
# Set to false to turn off verbose output.
16-
flag_verbose=true
12+
# Make cargo invocations verbose unless in quiet mode.
13+
# Also control bash debug output based on log level.
14+
case "${MAINTAINER_TOOLS_LOG_LEVEL:-verbose}" in
15+
quiet)
16+
export CARGO_TERM_VERBOSE=false
17+
export CARGO_TERM_QUIET=true
18+
;;
19+
*)
20+
export CARGO_TERM_VERBOSE=true
21+
export CARGO_TERM_QUIET=false
22+
set -x
23+
;;
24+
esac
1725

1826
# Use the current `Cargo.lock` file without updating it.
1927
cargo="cargo --locked"
@@ -32,6 +40,11 @@ TASK
3240
- docs Build docs with stable toolchain.
3341
- docsrs Build docs with nightly toolchain.
3442
- bench Run the bench tests.
43+
44+
Environment Variables:
45+
MAINTAINER_TOOLS_LOG_LEVEL Control script and cargo output verbosity.
46+
verbose (default) Show all script and cargo messages.
47+
quiet Suppress script messages, reduce cargo output.
3548
EOF
3649
}
3750

@@ -337,9 +350,14 @@ say_err() {
337350
}
338351

339352
verbose_say() {
340-
if [ "$flag_verbose" = true ]; then
341-
say "$1"
342-
fi
353+
case "${MAINTAINER_TOOLS_LOG_LEVEL:-verbose}" in
354+
quiet)
355+
# Suppress verbose output.
356+
;;
357+
*)
358+
say "$1"
359+
;;
360+
esac
343361
}
344362

345363
err() {

0 commit comments

Comments
 (0)