feat(legacy): +writeDash +helpers
This commit is contained in:
21
legacy/helper/posix-shell/log.sh
Normal file
21
legacy/helper/posix-shell/log.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/dash
|
||||
|
||||
log() {
|
||||
level="${1:?}"; shift
|
||||
case "$level" in
|
||||
trace) color="$MAGENTA" ;;
|
||||
debug) color="$BLUE" ;;
|
||||
info) color="$GREEN" ;;
|
||||
notice) color="$CYAN" ;;
|
||||
warn) color="$YELLOW" ;;
|
||||
error) color="$RED" ;;
|
||||
*) color="$WHITE" ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# shellcheck disable=SC1003
|
||||
fmt="$(printf "%s" "${1:?}" | sed 's/\\033\[0m/''\'"$color"'/g')"
|
||||
shift
|
||||
printf "%b\n" "$color$fmt$NC" "$@" >&2
|
||||
}
|
||||
Reference in New Issue
Block a user