modifié: m/log.py
modifié: superTornado.py
This commit is contained in:
parent
6cdbd96b7f
commit
94bfdc25d0
19
m/log.py
19
m/log.py
@ -1,5 +1,6 @@
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
@ -22,6 +23,10 @@ class Log(object):
|
||||
file_handler_error.setFormatter(formatter)
|
||||
self.logger.addHandler(file_handler_error)
|
||||
|
||||
steam_handler = logging.StreamHandler()
|
||||
steam_handler.setLevel(logging.DEBUG)
|
||||
logger.addHandler(steam_handler)
|
||||
|
||||
def enregDansLog(self,pLog,pMsg,pIP):
|
||||
with open("fichier/log", "a") as dest :
|
||||
d = datetime.now().strftime("%c")
|
||||
@ -29,18 +34,18 @@ class Log(object):
|
||||
|
||||
|
||||
def printL(self,pMsg,pLvl):
|
||||
self.logger.log(pLvl,pMsg)
|
||||
if pLvl == 10 :
|
||||
print bcolors.DEBUG + pMsg + bcolors.ENDC
|
||||
sys.stdout.write bcolors.DEBUG
|
||||
elif pLvl == 20 :
|
||||
print bcolors.INFO + pMsg + bcolors.ENDC
|
||||
sys.stdout.write bcolors.INFO
|
||||
elif pLvl == 25 :
|
||||
print bcolors.SUCCESS + pMsg + bcolors.ENDC
|
||||
sys.stdout.write bcolors.SUCCESS
|
||||
elif pLvl == 30 :
|
||||
print bcolors.WARNING + pMsg + bcolors.ENDC
|
||||
sys.stdout.write bcolors.WARNING
|
||||
elif pLvl == 40 :
|
||||
print bcolors.FAIL + pMsg + bcolors.ENDC
|
||||
|
||||
sys.stdout.write bcolors.FAIL
|
||||
self.logger.log(pLvl,pMsg)
|
||||
sys.stdout bcolors.ENDC
|
||||
|
||||
class bcolors:
|
||||
DEBUG = '\033[94m'
|
||||
|
@ -174,12 +174,13 @@ if __name__ == "__main__":
|
||||
sys.exit(1)
|
||||
print log.printL("->Configuration Server Load Successfully !",25)
|
||||
if blind == True:
|
||||
log.printL(" ->Blind unhabitant",20)
|
||||
log.printL(" +Blind unhabitant",20)
|
||||
else :
|
||||
log.printL(" ->Not blind unhabitant",20)
|
||||
log.printL(" ->Ip camera : " + ipCamera,20)
|
||||
log.printL(" ->Port Camera : " + portCamera,20)
|
||||
log.printL(" ->Port Server : " + portServ,20)
|
||||
log.printL(" +Not blind unhabitant",20)
|
||||
log.printL(" +Ip Camera : " + ipCamera,20)
|
||||
log.printL(" +Port Camera : " + portCamera,20)
|
||||
log.printL(" +Port Server : " + portServ,20)
|
||||
print ""
|
||||
|
||||
try :
|
||||
log.printL("->Server Start ...",20)
|
||||
@ -190,5 +191,5 @@ if __name__ == "__main__":
|
||||
tornado.ioloop.IOLoop.instance().start()
|
||||
except Exception, e :
|
||||
log.printL("Server Start Failed !",40)
|
||||
log.printL(e,40)
|
||||
log.printL(e.value,40)
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user