Skip to content

Commit 6741805

Browse files
committed
Adding logging
1 parent 9ac7ca2 commit 6741805

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

generate.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def get_method_case(method):
2222
exit(1)
2323

2424
def parse_line(line):
25-
line = line.replace('@sudo', '$SUDO')
25+
line = line\
26+
.replace('@sudo', '$SUDO')\
27+
.replace('@log', 'info')\
28+
.replace('@info', 'info')\
29+
.replace('@warn', 'warn')\
30+
.replace('@error', 'error')
2631
return line
2732

2833
def generate(path):
@@ -60,6 +65,23 @@ def generate(path):
6065
fi
6166
fi
6267
68+
RESET='\033[0m' # Red
69+
RED='\033[0;31m' # Red
70+
GREEN='\033[0;32m' # Green
71+
YELLOW='\033[0;33m' # Yellow
72+
log () {
73+
echo "[`date "+%Y.%m.%d-%H:%M:%S%Z"`]$1 $2"
74+
}
75+
info () {
76+
log "$GREEN INFO$RESET $1"
77+
}
78+
warn () {
79+
log "$YELLOW WARN$RESET $1"
80+
}
81+
error () {
82+
log "$RED ERROR$RESET $1"
83+
}
84+
6385
""")
6486

6587
seperator = "if"

0 commit comments

Comments
 (0)