-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.sh
53 lines (43 loc) · 831 Bytes
/
log.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
BOLD='\033[1m'
RED='\033[0;31m'
GREEN='\033[32m'
WHITE='\033[34m'
YELLOW='\033[33m'
NO_COLOR='\033[0m'
function info() {
(>&2 echo -e "[${WHITE}${BOLD}INFO${NO_COLOR}] $*")
}
function error() {
(>&2 echo -e "[${RED}ERROR${NO_COLOR}] $*")
}
function warning() {
(>&2 echo -e "${YELLOW}[WARNING] $*${NO_COLOR}")
}
function ok() {
(>&2 echo -e "[${GREEN}${BOLD} OK ${NO_COLOR}] $*")
}
function print_delim() {
echo '============================'
}
function get_now() {
echo $(date +%s)
}
function print_time() {
END_TIME=$(get_now)
ELAPSED_TIME=$(echo "$END_TIME - $START_TIME" | bc -l)
MESSAGE="Took ${ELAPSED_TIME} seconds"
info "${MESSAGE}"
}
function success() {
print_delim
ok "$1"
print_time
print_delim
}
function fail() {
print_delim
error "$1"
print_time
print_delim
exit -1
}