-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.py
25 lines (23 loc) · 936 Bytes
/
log.py
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
from time import gmtime, strftime
import json
bcolors={
"HEADER" : '\033[95m',
"INFO" : '\033[94m',
"SUCCESS" : '\033[92m',
"WARNING" : '\033[93m',
"FAIL" : '\033[91m',
"ENDC" : '\033[0m',
"BOLD" : '\033[1m',
"UNDERLINE" : '\033[4m'
}
config=json.loads(open("config.json","r").read())
def put(msg,type):
f=open(config["log_file"],"a")
print bcolors[type.upper()] + ""+"["+strftime("%Y-%m-%d %H:%M:%S", gmtime())+"]\t["+type.strip().capitalize()+"]\t"+msg+"" + bcolors["ENDC"]
f.write("["+strftime("%Y-%m-%d %H:%M:%S", gmtime())+"]\t["+type.strip().capitalize()+"]\t"+msg+"\n")
f.close()
def headPut(msg,type):
f=open(config["head_log_file"],"a")
print bcolors[type.upper()] + ""+"["+strftime("%Y-%m-%d %H:%M:%S", gmtime())+"]\t["+type.strip().capitalize()+"]\t"+msg+"" + bcolors["ENDC"]
f.write("["+strftime("%Y-%m-%d %H:%M:%S", gmtime())+"]\t["+type.strip().capitalize()+"]\t"+msg+"\n")
f.close()