You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

26 lines
660 B

import logging
# import chardet
from logging import handlers
from logging import exception
logger = logging.getLogger('file_unzip')
logger.setLevel(logging.DEBUG)
format_str = '%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s'
f = logging.Formatter(format_str)
hf = handlers.TimedRotatingFileHandler("log_out.log", when='midnight', interval=1, backupCount=7)
cf = logging.StreamHandler()
hf.setFormatter(f)
cf.setFormatter(f)
logger.addHandler(hf)
logger.addHandler(cf)
def log_info(msg):
try:
# chardet.detect(msg)
logger.info(msg)
except exception:
logger.info(msg.decode('utf-8').encode('gbk'))