Browse Source

new: redirect standard logs towards stderr if running an action

This allows direct actions to produce output that won't be messed
around by the logs.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
cache-relation 1.5.11
Valentin Lab 3 years ago
parent
commit
a93dc7c1fa
  1. 12
      bin/compose-core

12
bin/compose-core

@ -3850,6 +3850,10 @@ fi
_setup_state_dir _setup_state_dir
mkdir -p "$CACHEDIR" || exit 1 mkdir -p "$CACHEDIR" || exit 1
log () { cat; }
export -f log
## ##
## Argument parsing ## Argument parsing
## ##
@ -3887,6 +3891,8 @@ while read-0 arg; do
--quiet|-q) --quiet|-q)
export QUIET=true export QUIET=true
export wrap_opts+=("-q") export wrap_opts+=("-q")
log () { cat >&2; }
export -f log
;; ;;
--version|-V) --version|-V)
print_version print_version
@ -4081,6 +4087,10 @@ if [ -z "$is_docker_compose_action" -a "$action" ]; then
esac esac
} < <(has_service_action "$action_service" "$action") } < <(has_service_action "$action_service" "$action")
services_args=("$action_service") services_args=("$action_service")
## Divert logging to stdout to stderr
log () { cat >&2; }
export -f log
else else
die "Unknown action '${DARKCYAN}$action$NORMAL': It doesn't match any docker-compose commands nor inner charm actions." die "Unknown action '${DARKCYAN}$action$NORMAL': It doesn't match any docker-compose commands nor inner charm actions."
fi fi
@ -4185,7 +4195,7 @@ if [ -n "$full_init" ]; then
run_service_hook pre_deploy "${services_args[@]}" || exit 1 run_service_hook pre_deploy "${services_args[@]}" || exit 1
fi
fi | log
if [ "$action" == "run" -a "${#services_args}" != 0 ]; then if [ "$action" == "run" -a "${#services_args}" != 0 ]; then
charm=$(get_service_charm "${services_args[0]}") || exit 1 charm=$(get_service_charm "${services_args[0]}") || exit 1

Loading…
Cancel
Save