From 311d42283b2a0a022f8827fb0927ca30601fbb73 Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751NSS@gmail.com> Date: Sun, 4 Feb 2024 20:06:34 +0800 Subject: [PATCH] feat: fix openim logs and ci (#1878) --- scripts/lib/logging.sh | 14 +++++++++++--- scripts/lib/util.sh | 4 ---- scripts/start-all.sh | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 2fa77dd83..8f2bb33cf 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -131,16 +131,24 @@ openim::log::error_exit() { exit "${code}" } -# Log an error but keep going. Don't dump the stack or exit. +# Log an error but keep going. Don't dump the stack or exit. openim::log::error() { + # Define red color + red='\033[0;31m' + # No color (reset) + nc='\033[0m' # No Color + timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") - echo_log "!!! ${timestamp} ${1-}" >&2 + # Apply red color for error message + echo_log "${red}!!! ${timestamp} ${1-}${nc}" >&2 shift for message; do - echo_log " ${message}" >&2 + # Apply red color for subsequent lines of the error message + echo_log "${red} ${message}${nc}" >&2 done } + # Print an usage message to stderr. The arguments are printed directly. openim::log::usage() { echo_log >&2 diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index b93f45205..eaefaf22a 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -1541,12 +1541,8 @@ openim::util::check_ports() { if [[ "$OSTYPE" == "linux-gnu"* ]]; then if command -v ss > /dev/null 2>&1; then info=$(ss -ltnp | grep ":$port" || true) - openim::color::echo $COLOR_RED "!!!!!!!! port=$port" - openim::color::echo $COLOR_RED "!!!!!!!! info=$info" else info=$(netstat -ltnp | grep ":$port" || true) - openim::color::echo $COLOR_RED "!!!!!!!! port=$port" - openim::color::echo $COLOR_RED "!!!!!!!! info=$info" fi elif [[ "$OSTYPE" == "darwin"* ]]; then # For macOS, use lsof diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 5f34cbdbe..ca03f0c3c 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -82,4 +82,4 @@ execute_scripts openim::log::info "\n## Post Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::log::success "✨ All OpenIM services have been successfully started!" \ No newline at end of file +openim::color::echo $COLOR_BLUE "✨ All OpenIM services have been successfully started!" \ No newline at end of file