modifié: m/loadConf.py
modifié: m/log.py modifié: superTornado.py
This commit is contained in:
parent
d3a9e6ee2a
commit
3e16d6c474
@ -33,20 +33,6 @@ class ConfigError(Exception):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.value)
|
return repr(self.value)
|
||||||
|
|
||||||
class bcolors:
|
|
||||||
HEADER = '\033[95m'
|
|
||||||
OKBLUE = '\033[94m'
|
|
||||||
OKGREEN = '\033[92m'
|
|
||||||
WARNING = '\033[93m'
|
|
||||||
FAIL = '\033[91m'
|
|
||||||
ENDC = '\033[0m'
|
|
||||||
|
|
||||||
def disable(self):
|
|
||||||
self.HEADER = ''
|
|
||||||
self.OKBLUE = ''
|
|
||||||
self.OKGREEN = ''
|
|
||||||
self.WARNING = ''
|
|
||||||
self.FAIL = ''
|
|
||||||
self.ENDC = ''
|
|
||||||
|
|
||||||
|
|
||||||
|
56
m/log.py
56
m/log.py
@ -4,8 +4,64 @@ import time
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
class Log(object):
|
class Log(object):
|
||||||
|
def __init__(self) :
|
||||||
|
self.logger = logging.getLogger()
|
||||||
|
self.logger.setLevel(logging.DEBUG)
|
||||||
|
formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s')
|
||||||
|
file_handler = RotatingFileHandler('activity.log', 'a', 1000000, 1)
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
self.logger.addHandler(file_handler)
|
||||||
|
|
||||||
def enregDansLog(self,pLog,pMsg,pIP):
|
def enregDansLog(self,pLog,pMsg,pIP):
|
||||||
with open("fichier/log", "a") as dest :
|
with open("fichier/log", "a") as dest :
|
||||||
d = datetime.now().strftime("%c")
|
d = datetime.now().strftime("%c")
|
||||||
dest.write("%s,%s,%s,%s\n" % (d,pLog,pMsg,pIP))
|
dest.write("%s,%s,%s,%s\n" % (d,pLog,pMsg,pIP))
|
||||||
|
|
||||||
|
|
||||||
|
def printL(self,pMsg,pLvl)
|
||||||
|
logger.log(pMsg, pLvl)
|
||||||
|
if pLvl == 10
|
||||||
|
print bcolors.DEBUG ,
|
||||||
|
elif pLvl == 20 :
|
||||||
|
print bcolors.INFO ,
|
||||||
|
elif pLvl == 30 :
|
||||||
|
print bcolors.WARNING ,
|
||||||
|
elif pLvl == 40 :
|
||||||
|
print bcolors.FAIL ,
|
||||||
|
print pMsg
|
||||||
|
print bcolors.ENDC ,
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class bcolors:
|
||||||
|
NOTSET = '\033[95m'
|
||||||
|
DEBUG = '\033[94m'
|
||||||
|
INFO = '\033[92m'
|
||||||
|
WARNING = '\033[93m'
|
||||||
|
FAIL = '\033[91m'
|
||||||
|
ENDC = '\033[0m'
|
||||||
|
|
||||||
|
def disable(self):
|
||||||
|
self.HEADER = ''
|
||||||
|
self.OKBLUE = ''
|
||||||
|
self.OKGREEN = ''
|
||||||
|
self.WARNING = ''
|
||||||
|
self.FAIL = ''
|
||||||
|
self.ENDC = ''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# création d'un second handler qui va rediriger chaque écriture de log
|
||||||
|
# sur la console
|
||||||
|
|
||||||
|
# Après 3 heures, on peut enfin logguer
|
||||||
|
# Il est temps de spammer votre code avec des logs partout :
|
||||||
|
logger.info('Hello')
|
||||||
|
logger.warning('Testing %s', 'foo')
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ application = tornado.web.Application([
|
|||||||
cookie_secret="1213215656")
|
cookie_secret="1213215656")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print bcolors.HEADER + "->Loading configuration ... " + bcolors.ENDC
|
printL ("->Loading configuration ... ", 20 )
|
||||||
try :
|
try :
|
||||||
blind = config.isBlind()
|
blind = config.isBlind()
|
||||||
ipCamera = config.ipCamera()
|
ipCamera = config.ipCamera()
|
||||||
@ -178,6 +178,7 @@ if __name__ == "__main__":
|
|||||||
else :
|
else :
|
||||||
print " ->Not blind unhabitant"
|
print " ->Not blind unhabitant"
|
||||||
print " ->Ip camera : " + ipCamera
|
print " ->Ip camera : " + ipCamera
|
||||||
|
print " ->Port Camera : " + portCamera
|
||||||
print " ->Port Server : " + portServ
|
print " ->Port Server : " + portServ
|
||||||
tornado.options.parse_command_line()
|
tornado.options.parse_command_line()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user