log
This commit is contained in:
parent
5d616fd920
commit
6e19ca602f
@ -6,11 +6,11 @@ class bcolors:
|
|||||||
"""
|
"""
|
||||||
Define constant color value for different level
|
Define constant color value for different level
|
||||||
"""
|
"""
|
||||||
DEBUG = '\033[94m'
|
DEBUG = '\033[94m '
|
||||||
INFO = '\033[95m'
|
INFO = ' \033[95m '
|
||||||
WARNING = '\033[93m'
|
WARNING = ' \033[93m '
|
||||||
FAIL = '\033[91m'
|
FAIL = ' \033[91m '
|
||||||
ENDC = '\033[0m'
|
ENDC = ' \033[0m '
|
||||||
|
|
||||||
class lvl:
|
class lvl:
|
||||||
"""
|
"""
|
||||||
@ -21,6 +21,7 @@ class lvl:
|
|||||||
INFO = 20
|
INFO = 20
|
||||||
WARNING = 30
|
WARNING = 30
|
||||||
FAIL = 40
|
FAIL = 40
|
||||||
|
CRITICAL = 50
|
||||||
|
|
||||||
class SingleLevelFilter(logging.Filter):
|
class SingleLevelFilter(logging.Filter):
|
||||||
"""Filter for one level"""
|
"""Filter for one level"""
|
||||||
@ -50,7 +51,6 @@ class Log(object):
|
|||||||
error.log -> error
|
error.log -> error
|
||||||
Write all message on terminal too
|
Write all message on terminal too
|
||||||
"""
|
"""
|
||||||
logging.addLevelName(lvl.SUCCESS, "SUCCESS")
|
|
||||||
self.logger = logging.getLogger()
|
self.logger = logging.getLogger()
|
||||||
self.logger.setLevel(logging.DEBUG)
|
self.logger.setLevel(logging.DEBUG)
|
||||||
formatter = logging.Formatter('%(asctime)-15s :: %(levelname)s :: %(message)s')
|
formatter = logging.Formatter('%(asctime)-15s :: %(levelname)s :: %(message)s')
|
||||||
@ -72,20 +72,20 @@ class Log(object):
|
|||||||
self.logger.addHandler(steam_handler)
|
self.logger.addHandler(steam_handler)
|
||||||
|
|
||||||
|
|
||||||
def printL(self,pMsg,pLvl):
|
def printL(self,pMsg,pLvl):
|
||||||
"""
|
"""
|
||||||
Add color and write in log with an define level
|
Add color and write in log with an define level
|
||||||
pMsg : message to write in log
|
pMsg : message to write in log
|
||||||
pLvl : level of log message
|
pLvl : level of log message
|
||||||
"""
|
"""
|
||||||
if pLvl == lvl.DEBUG :
|
if pLvl == lvl.DEBUG :
|
||||||
pMsg = bcolors.DEBUG + str(pMsg) + bcolors.ENDC
|
pMsg = bcolors.DEBUG + str(pMsg) + bcolors.ENDC
|
||||||
elif pLvl == lvl.INFO :
|
elif pLvl == lvl.INFO :
|
||||||
pMsg = bcolors.INFO + str(pMsg) + bcolors.ENDC
|
pMsg = bcolors.INFO + str(pMsg) + bcolors.ENDC
|
||||||
elif pLvl == lvl.SUCCESS :
|
elif pLvl == lvl.SUCCESS :
|
||||||
pMsg = bcolors.SUCCESS + str(pMsg) + bcolors.ENDC
|
pMsg = bcolors.SUCCESS + str(pMsg) + bcolors.ENDC
|
||||||
elif pLvl == lvl.WARNING :
|
elif pLvl == lvl.WARNING :
|
||||||
pMsg = bcolors.WARNING + str(pMsg) + bcolors.ENDC
|
pMsg = bcolors.WARNING + str(pMsg) + bcolors.ENDC
|
||||||
elif pLvl == lvl.FAIL :
|
elif pLvl == lvl.FAIL :
|
||||||
pMsg = bcolors.FAIL + str(pMsg) + bcolors.ENDC
|
pMsg = bcolors.FAIL + str(pMsg) + bcolors.ENDC
|
||||||
self.logger.log(pLvl,pMsg)
|
self.logger.log(pLvl,pMsg)
|
Reference in New Issue
Block a user