Merge pull request #9576 from id/chore-fix-bin-emqx-logging-on-non-tty

chore: fix logging in bin/emqx on non-tty
This commit is contained in:
Zaiming (Stone) Shi 2022-12-21 09:47:00 +01:00 committed by GitHub
commit 9066513bef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -54,11 +54,19 @@ export ERTS_LIB_DIR="$RUNNER_ROOT_DIR/lib"
DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs" DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs"
logerr() { logerr() {
if [ "${TERM:-dumb}" = dumb ]; then
echo -e "ERROR: $*" 1>&2
else
echo -e "$(tput setaf 1)ERROR: $*$(tput sgr0)" 1>&2 echo -e "$(tput setaf 1)ERROR: $*$(tput sgr0)" 1>&2
fi
} }
logwarn() { logwarn() {
if [ "${TERM:-dumb}" = dumb ]; then
echo "WARNING: $*"
else
echo "$(tput setaf 3)WARNING: $*$(tput sgr0)" echo "$(tput setaf 3)WARNING: $*$(tput sgr0)"
fi
} }
die() { die() {