/
log
executable file
·29 lines (24 loc) · 1.26 KB
/
log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi
if [[ ! -z "$2" ]] ; then level=$1 ; shift ; else level="info" ; fi
message=$1
if [[ -z "$rvm_interactive" ]] ; then
case "$level" in
debug) shift ; echo -e "\n$(tput setaf 5)<d>$(tput sgr0) $message $(tput setaf 5)</d> $(tput sgr0) \n" ;;
info) shift ; echo -e "\n$(tput setaf 2)<i>$(tput sgr0) $message $(tput setaf 2)</i> $(tput sgr0) \n" ;;
warn) shift ; echo -e "\n$(tput setaf 3)<w>$(tput sgr0) $message $(tput setaf 3)</w> $(tput sgr0) \n" ;;
error) shift ; echo -e "\n$(tput setaf 1)<e>$(tput sgr0) $message $(tput setaf 1)</e> $(tput sgr0) \n" >&2 ;;
fail) shift ; echo -e "\n$(tput setaf 1)<f>$(tput sgr0) $message $(tput setaf 1)</f> $(tput sgr0) \n" >&2 ;;
*) echo -e "$message"
esac
else
case "$level" in
debug) shift ; echo -e "\n$(tput setaf 5)$message$(tput sgr0)\n" ;;
info) shift ; echo -e "\n$(tput setaf 2)$message$(tput sgr0)\n" ;;
warn) shift ; echo -e "\n$(tput setaf 3)$message$(tput sgr0)\n" ;;
error) shift ; echo -e "\n$(tput setaf 1)$message$(tput sgr0)\n" >&2 ;;
fail) shift ; echo -e "\n$(tput setaf 1)$message$(tput sgr0)\n" >&2 ;;
*) echo -e "$message"
esac
fi
exit 0