赞
踩
import threading
import time
import logging
import logging.handlers
LEVELS={'notset':logging.DEBUG,
'debug':logging.DEBUG,
'info':logging.INFO,
'warning':logging.WARNING,
'error':logging.ERROR,
'critical':logging.CRITICAL}
LOG_FILENAME = 'test.log'
LOG_BACKUPCOUNT = 5
LOG_LEVEL = 'notset'
def InitLog(file_name,logger):
LOG_FILENAME = file_name
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME,maxBytes=10*1024*1024,backupCount=LOG_BACKUPCOUNT)
#handler = logging.FileHandler(LOG_FILENAME)
formatter = logging.Formatter("[ %(asctime)s ][ %(levelname)s ] %(message)s\n")
handler.setFormatter(formatter)
#logger = logging.getLogger()
logger.addHandler(handler
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。