-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinclude.1.conf
74 lines (67 loc) · 1.42 KB
/
include.1.conf
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#
# Config snippet
#
# Author: mail _^_ AT _^_ wangbo _^_ im
#
LOG_LEVEL="${LOG_LEVEL:-WARN}"
FATAL_LEVEL=0
WARN_LEVEL=10
INFO_LEVEL=20
DEBUG_LEVEL=30
#
# $1: log level
# $2 .. $N: additional args
__log() {
local enabled_log_level="$LOG_LEVEL"
case "$enabled_log_level" in
FATAL)
enabled_log_level=$FATAL_LEVEL
;;
WARN)
enabled_log_level=$WARN_LEVEL
;;
INFO)
enabled_log_level=$INFO_LEVEL
;;
DEBUG)
enabled_log_level=$DEBUG_LEVEL
;;
*)
enabled_log_level=$WARN_LEVEL
;;
esac
local log_level=$1
shift
if [ $log_level -le $enabled_log_level ]; then
case $log_level in
$DEBUG_LEVEL)
echo -e "\033[0m[DEBUG] $@ \033[0m"
;;
$INFO_LEVEL)
echo -e "\033[0;1;32m[INFO] $@ \033[0m"
;;
$WARN_LEVEL)
echo -e "\033[0;1;35m[WARN] $@ \033[0m"
;;
$FATAL_LEVEL)
echo -e "\033[0;1;31m[FATAL] $@ \033[0m"
;;
*)
# Do nothing
;;
esac
fi
}
__fatal() {
__log $FATAL_LEVEL $@
}
__warn() {
__log $WARN_LEVEL $@
}
__info() {
__log $INFO_LEVEL $@
}
__debug() {
__log $DEBUG_LEVEL $@
}
# vim:set nu rnu list et sr ts=4 sw=4 ft=sh: