modifié: m/log.py

modifié:         superTornado.py
This commit is contained in:
sidya82 2014-03-03 14:52:50 +01:00
parent eb3455bc71
commit 91d27e848b
2 changed files with 5 additions and 10 deletions

View File

@ -8,7 +8,6 @@ class Log(object):
def __init__(self) : def __init__(self) :
logging.addLevelName(25, "SUCCESS") logging.addLevelName(25, "SUCCESS")
logging.addLevelName(45, "ILLEGALUSER")
self.logger = logging.getLogger() self.logger = logging.getLogger()
self.logger.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG)
@ -19,17 +18,13 @@ class Log(object):
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
self.logger.addHandler(file_handler) self.logger.addHandler(file_handler)
file_handler_error = RotatingFileHandler('error.log', 'a', 1000000, 1) file_handler_error = RotatingFileHandler('error.log', 'a', 1000000, 1)
file_handler_error.setLevel(logging.ERROR) file_handler_error.setLevel(logging.ERROR)
file_handler_error.setFormatter(formatter) file_handler_error.setFormatter(formatter)
self.logger.addHandler(file_handler_error) self.logger.addHandler(file_handler_error)
file_handler = RotatingFileHandler('illegal.log', 'a', 1000000, 1)
file_handler.setLevel(logging.ILLEGALUSER)
file_handler.setFormatter(formatter)
self.logger.addHandler(file_handler)
steam_handler = logging.StreamHandler() steam_handler = logging.StreamHandler()
steam_handler.setLevel(logging.NOTSET) steam_handler.setLevel(logging.NOTSET)
self.logger.addHandler(steam_handler) self.logger.addHandler(steam_handler)
@ -44,7 +39,7 @@ class Log(object):
pMsg = bcolors.SUCCESS + pMsg + bcolors.ENDC pMsg = bcolors.SUCCESS + pMsg + bcolors.ENDC
elif pLvl == 30 : elif pLvl == 30 :
pMsg = bcolors.WARNING + pMsg + bcolors.ENDC pMsg = bcolors.WARNING + pMsg + bcolors.ENDC
elif pLvl == 40 or pLvl ==45 : elif pLvl == 40 :
pMsg = bcolors.FAIL + pMsg + bcolors.ENDC pMsg = bcolors.FAIL + pMsg + bcolors.ENDC
self.logger.log(pLvl,pMsg) self.logger.log(pLvl,pMsg)

View File

@ -98,7 +98,7 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
log.printL('->Send visual alarm authorized user',20) log.printL('->Send visual alarm authorized user',20)
log.printL('maison.request("GET", "micom/lamp.php?room=salon1&order=1")',10) log.printL('maison.request("GET", "micom/lamp.php?room=salon1&order=1")',10)
else : else :
log.printL(iden + " as IllegalUser,Unauthorized user connection" + self.request.remote_ip,45) log.printL(iden + " as IllegalUser,Unauthorized user connection" + self.request.remote_ip,30)
if blind == True: if blind == True:
log.printL('->Send audio alarm unauthorized user',30) log.printL('->Send audio alarm unauthorized user',30)
log.printL('maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20non%20autorisee")',10) log.printL('maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20non%20autorisee")',10)
@ -117,7 +117,7 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
if self.get_autorisation == "yes": if self.get_autorisation == "yes":
log.printL(iden+",Authorized user deconnection,"+self.request.remote_ip,20) log.printL(iden+",Authorized user deconnection,"+self.request.remote_ip,20)
else : else :
log.printL(iden +" as IllegalUser,Unauthorized user deconnection,"+self.request.remote_ip,45) log.printL(iden +" as IllegalUser,Unauthorized user deconnection,"+self.request.remote_ip,30)
if blind == True: if blind == True:
log.printL('->Send audio alarm deconnection user', 20) log.printL('->Send audio alarm deconnection user', 20)