-
Notifications
You must be signed in to change notification settings - Fork 4
/
Loggin.py
executable file
·45 lines (38 loc) · 1.78 KB
/
Loggin.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
class base(object):
def __init__(self):
self.classname = self.__class__.__name__
self.errorcolor = "\033[31m"#red
self.infocolor = "\033[34m"#blue
self.warningcolor = "\033[33m"#yellow
self.successcolor = "\033[32m"#green
self.endcolor = "\033[0m"#reset
self.prependfunction = True
self.basemembers = ["classname","errorcolor","infocolor","warningcolor","successcolor","endcolor","prependfunction"]
def error(self,message, functionname = ""):
printstring = ""
if functionname == "":
printstring = "\n"+self.errorcolor+"*** Error ["+self.classname+"]: "+message+" ***\n"+self.endcolor
else:
printstring = "\n"+self.errorcolor+"*** Error ["+self.classname+"::"+functionname+"]: "+message+" ***\n"+self.endcolor
sys.exit(printstring)
def info(self,message,newline=True):
printstring = self.infocolor+"["+self.classname+"]: "+message+self.endcolor
if newline:
print printstring
else:
print self.infocolor+message+self.endcolor,
sys.stdout.flush()
def warning(self,message,functionname = ""):
printstring = ""
if functionname == "":
printstring = self.warningcolor+"["+self.classname+"] Warning: "+message+self.endcolor
else:
printstring = self.warningcolor+"["+self.classname+"::"+functionname+"] Warning: "+message+self.endcolor
print printstring
def success(self,message):
printstring = self.successcolor+"["+self.classname+"]: "+message+self.endcolor
print printstring
def progress(self,message="."):
string = self.infocolor+message+self.endcolor
print string