From 94bfdc25d07bc35c0eeda9a6b836bafdd6148cf4 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Mon, 3 Mar 2014 14:09:06 +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 | 19 ++++++++++++------- superTornado.py | 13 +++++++------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/m/log.py b/m/log.py index 1147b6c..22ff035 100644 --- a/m/log.py +++ b/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' diff --git a/superTornado.py b/superTornado.py index 2323e91..ade01a0 100644 --- a/superTornado.py +++ b/superTornado.py @@ -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)