-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.py
23 lines (23 loc) · 888 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
from time import 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("nconfig.json","r").read())
def putmsg(mssg,code):
f=open(config["logfile"],"a")
print bcolors[code.upper()]+""+"["+strftime("%Y-%m-%d %H:%M:%S")+"]\t["+code.strip().capitalize()+"]\t"+mssg+"" + bcolors["ENDC"]
f.write("["+strftime("%Y-%m-%d %H:%M:%S")+"]\t["+code.strip().capitalize()+"]\t"+mssg+"\n")
f.close()
def headmsg(mssg,code):
f=open(config["head_log"],"a")
print bcolors[code.upper()] + ""+"["+strftime("%Y-%m-%d %H:%M:%S")+"]\t["+code.strip().capitalize()+"]\t"+mssg+"" + bcolors["ENDC"]
f.write("["+strftime("%Y-%m-%d %H:%M:%S")+"]\t["+code.strip().capitalize()+"]\t"+mssg+"\n")
f.close()