modifié: m/log.py
modifié: superTornado.py
This commit is contained in:
parent
a2daaf84e5
commit
d3a9e6ee2a
22
m/log.py
22
m/log.py
@ -4,22 +4,8 @@ import time
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
class Log(object):
|
class Log(object):
|
||||||
def __init__(self) :
|
def enregDansLog(self,pLog,pMsg,pIP):
|
||||||
self.logger = logging.getLogger()
|
with open("fichier/log", "a") as dest :
|
||||||
self.logger.setLevel(logging.DEBUG)
|
d = datetime.now().strftime("%c")
|
||||||
|
dest.write("%s,%s,%s,%s\n" % (d,pLog,pMsg,pIP))
|
||||||
|
|
||||||
formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s')
|
|
||||||
file_handler = RotatingFileHandler('m/fichier/log', 'a', 1000000, 1)
|
|
||||||
|
|
||||||
file_handler.setLevel(logging.DEBUG)
|
|
||||||
file_handler.setFormatter(formatter)
|
|
||||||
self.logger.addHandler(file_handler)
|
|
||||||
|
|
||||||
|
|
||||||
steam_handler = logging.StreamHandler()
|
|
||||||
steam_handler.setLevel(logging.DEBUG)
|
|
||||||
self.logger.addHandler(steam_handler)
|
|
||||||
|
|
||||||
|
|
||||||
def printL(self,pMsg):
|
|
||||||
self.logger.info(pMsg)
|
|
||||||
|
@ -36,7 +36,6 @@ class BaseHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
class MainHandler(BaseHandler):
|
class MainHandler(BaseHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
print ("->")
|
|
||||||
self.render("v/index.html")
|
self.render("v/index.html")
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
@ -91,8 +90,8 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
print "->Websocket opened : " + self.request.remote_ip
|
print "->Websocket opened : " + self.request.remote_ip
|
||||||
iden = self.current_user
|
iden = self.current_user
|
||||||
if self.get_autorisation == "yes":
|
if self.get_autorisation == "yes":
|
||||||
ficLog.printL(iden +" Authorized user connection " + self.request.remote_ip)
|
ficLog.enregDansLog(iden,"Authorized user connection",self.request.remote_ip)
|
||||||
if blind == True:
|
if confAveug == True:
|
||||||
print '->Send audio alarm authorized user'
|
print '->Send audio alarm authorized user'
|
||||||
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20autorisee")'
|
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20autorisee")'
|
||||||
else:
|
else:
|
||||||
@ -100,8 +99,8 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
||||||
print "->Authorized user access : " + self.request.remote_ip
|
print "->Authorized user access : " + self.request.remote_ip
|
||||||
else :
|
else :
|
||||||
ficLog.printL(iden + " as IllegalUser Unauthorized user connection" + self.request.remote_ip)
|
ficLog.enregDansLog(iden + " as IllegalUser","Unauthorized user connection",self.request.remote_ip)
|
||||||
if blind == True:
|
if confAveug == True:
|
||||||
print '->Send audio alarm unauthorized user'
|
print '->Send audio alarm unauthorized user'
|
||||||
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20non%20autorisee")'
|
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20non%20autorisee")'
|
||||||
else:
|
else:
|
||||||
@ -118,11 +117,11 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
print "->Websocket closed : "+self.request.remote_ip
|
print "->Websocket closed : "+self.request.remote_ip
|
||||||
iden = self.current_user
|
iden = self.current_user
|
||||||
if self.get_autorisation == "yes":
|
if self.get_autorisation == "yes":
|
||||||
ficLog.printL(iden +" Authorized user deconnection " + self.request.remote_ip)
|
ficLog.enregDansLog(iden,"Authorized user deconnection",self.request.remote_ip)
|
||||||
else :
|
else :
|
||||||
ficLog.printL(iden + " as IllegalUser Unauthorized user deconnection" + self.request.remote_ip)
|
ficLog.enregDansLog(iden + " as IllegalUser","Unauthorized user deconnection",self.request.remote_ip)
|
||||||
|
|
||||||
if blind == True:
|
if confAveug == True:
|
||||||
print '->Send audio alarm deconnection user'
|
print '->Send audio alarm deconnection user'
|
||||||
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20rompue")'
|
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20rompue")'
|
||||||
else:
|
else:
|
||||||
@ -155,9 +154,7 @@ application = tornado.web.Application([
|
|||||||
cookie_secret="1213215656")
|
cookie_secret="1213215656")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print bcolors.HEADER ,
|
print bcolors.HEADER + "->Loading configuration ... " + bcolors.ENDC
|
||||||
ficLog.printL("->Loading configuration ... ")
|
|
||||||
print bcolors.ENDC ,
|
|
||||||
try :
|
try :
|
||||||
blind = config.isBlind()
|
blind = config.isBlind()
|
||||||
ipCamera = config.ipCamera()
|
ipCamera = config.ipCamera()
|
||||||
|
Reference in New Issue
Block a user