From eb3455bc713c8b87b126800f39f1c6c7ff524730 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Mon, 3 Mar 2014 14:49:21 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20m/lo?= =?UTF-8?q?g.py=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20superTornado.?= =?UTF-8?q?py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- m/log.py | 9 ++++++++- superTornado.py | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/m/log.py b/m/log.py index 0b9766f..0ab730b 100644 --- a/m/log.py +++ b/m/log.py @@ -8,6 +8,7 @@ class Log(object): def __init__(self) : logging.addLevelName(25, "SUCCESS") + logging.addLevelName(45, "ILLEGALUSER") self.logger = logging.getLogger() self.logger.setLevel(logging.DEBUG) @@ -23,6 +24,12 @@ class Log(object): file_handler_error.setFormatter(formatter) 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.setLevel(logging.NOTSET) self.logger.addHandler(steam_handler) @@ -37,7 +44,7 @@ class Log(object): pMsg = bcolors.SUCCESS + pMsg + bcolors.ENDC elif pLvl == 30 : pMsg = bcolors.WARNING + pMsg + bcolors.ENDC - elif pLvl == 40 : + elif pLvl == 40 or pLvl ==45 : pMsg = bcolors.FAIL + pMsg + bcolors.ENDC self.logger.log(pLvl,pMsg) diff --git a/superTornado.py b/superTornado.py index 11d5a6a..0e8f714 100644 --- a/superTornado.py +++ b/superTornado.py @@ -98,7 +98,7 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler): log.printL('->Send visual alarm authorized user',20) log.printL('maison.request("GET", "micom/lamp.php?room=salon1&order=1")',10) else : - log.printL(iden + " as IllegalUser,Unauthorized user connection" + self.request.remote_ip,30) + log.printL(iden + " as IllegalUser,Unauthorized user connection" + self.request.remote_ip,45) if blind == True: 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) @@ -117,9 +117,9 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler): if self.get_autorisation == "yes": log.printL(iden+",Authorized user deconnection,"+self.request.remote_ip,20) else : - log.printL(iden +" as IllegalUser,Unauthorized user deconnection,"+self.request.remote_ip,30) + log.printL(iden +" as IllegalUser,Unauthorized user deconnection,"+self.request.remote_ip,45) - if confAveug == True: + if blind == True: log.printL('->Send audio alarm deconnection user', 20) log.printL('maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20rompue")',10) else: