Skip to content

Commit

Permalink
feat(lib): add debug log func with color option via env T0_COLOR
Browse files Browse the repository at this point in the history
  • Loading branch information
tcodes0 committed Sep 10, 2024
1 parent 97f492e commit a35252e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export LIB_COLOR_FAIL="\e[2;7;38;05;197;47m FAIL \e[0m"
# ANSI escape codes for visual formatting
export LIB_VISUAL_END="\e[0m"
export LIB_FORMAT_DIM="\e[2m"
export LIB_COLOR_DARK_GRAY="\e[38;05;8m"

# on most systems, sed is GNU sed
export SED="sed"
Expand Down Expand Up @@ -73,6 +74,19 @@ log() {
__log INFO "$@"
}

# Description: Log a message with DEBUG level and line number
# Globals : T0_COLOR (env) colored output if "true"
# Args : Any
# STDERR : INFO (pizza.sh:34) message + \n
# Example : log $LINENO pizza order received
debug() {
if [ "${T0_COLOR:-}" == "true" ]; then
__log "${LIB_COLOR_DARK_GRAY}DEBUG" "$@" "${LIB_VISUAL_END}"
else
__log DEBUG "$@"
fi
}

# Description: Log a message with ERROR level and line number
# Args : Any
# STDERR : ERROR (pizza.sh:34) message + \n
Expand Down

0 comments on commit a35252e

Please sign in to comment.