From 4a9be95f6d3eafaffe067312c38c4399c7cbea83 Mon Sep 17 00:00:00 2001 From: Ivan Dyachkov Date: Mon, 19 Dec 2022 14:53:28 +0100 Subject: [PATCH] chore: fix logging in bin/emqx on non-tty --- bin/emqx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/emqx b/bin/emqx index 80d057dd1..e2e49a62e 100755 --- a/bin/emqx +++ b/bin/emqx @@ -54,11 +54,19 @@ export ERTS_LIB_DIR="$RUNNER_ROOT_DIR/lib" DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs" logerr() { - echo -e "$(tput setaf 1)ERROR: $*$(tput sgr0)" 1>&2 + if [ "${TERM:-dumb}" = dumb ]; then + echo -e "ERROR: $*" 1>&2 + else + echo -e "$(tput setaf 1)ERROR: $*$(tput sgr0)" 1>&2 + fi } logwarn() { - echo "$(tput setaf 3)WARNING: $*$(tput sgr0)" + if [ "${TERM:-dumb}" = dumb ]; then + echo "WARNING: $*" + else + echo "$(tput setaf 3)WARNING: $*$(tput sgr0)" + fi } die() {