From 23ff16a575cff3e5356615a99e9140a8958f1432 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Mon, 3 Mar 2014 13:13:00 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20m/lo?= =?UTF-8?q?g.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- m/log.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/m/log.py b/m/log.py index 2e43008..878d2a5 100644 --- a/m/log.py +++ b/m/log.py @@ -7,12 +7,17 @@ class Log(object): def __init__(self) : self.logger = logging.getLogger() self.logger.setLevel(logging.DEBUG) - formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s') + formatter = logging.Formatter('%(asctime)-15s :: %(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) + file_handler_error = RotatingFileHandler('error.log', 'a', 1000000, 1) + file_handler_error.setLevel(logging.ERROR) + file_handler_error.setFormatter(formatter) + self.logger.addHandler(file_handler_error) + def enregDansLog(self,pLog,pMsg,pIP): with open("fichier/log", "a") as dest : d = datetime.now().strftime("%c") @@ -22,15 +27,15 @@ class Log(object): def printL(self,pMsg,pLvl): self.logger.log(pLvl,pMsg) if pLvl == 10 : - print bcolors.DEBUG , + print bcolors.DEBUG, elif pLvl == 20 : - print bcolors.INFO , + print bcolors.INFO, elif pLvl == 30 : - print bcolors.WARNING , + print bcolors.WARNING, elif pLvl == 40 : - print bcolors.FAIL , + print bcolors.FAIL, print pMsg - print bcolors.ENDC , + print bcolors.ENDC, class bcolors: NOTSET = '\033[95m'