Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Color Logging for Error Messages #1878

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/lib/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions scripts/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/start-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
openim::color::echo $COLOR_BLUE "✨ All OpenIM services have been successfully started!"
Loading