import logging # from ..config import config from Config.config import config log_level = config.get('log_level') log_file_name = config.get('log_file_name_jd_xf') def get_logger(log_level): formatter_str = '%(asctime)s %(levelname)s [%(processName)s] [%(threadName)s] - %(message)s' formatter = logging.Formatter(formatter_str) logging.basicConfig(level=logging.DEBUG, format=formatter_str) Logger = logging.getLogger() file_handler = logging.FileHandler(log_file_name) file_handler.setFormatter(formatter) Logger.addHandler(file_handler) if log_level == 'debug': level = logging.DEBUG elif log_level == 'info': level = logging.INFO else: level = logging.WARNING Logger.setLevel(level) return Logger Logger = get_logger(log_level)
import logging from Config.config import config log_level = config.get('log_level') log_file_name = config.get('log_file_name_tmall_my') def get_logger(log_level): formatter_str = '%(asctime)s %(levelname)s [%(processName)s] [%(threadName)s] - %(message)s' formatter = logging.Formatter(formatter_str) logging.basicConfig(level=logging.DEBUG, format=formatter_str) Logger = logging.getLogger() file_handler = logging.FileHandler(log_file_name) file_handler.setFormatter(formatter) Logger.addHandler(file_handler) if log_level == 'debug': level = logging.DEBUG elif log_level == 'info': level = logging.INFO else: level = logging.WARNING Logger.setLevel(level) return Logger Logger = get_logger(log_level)
import logging from Config.config import config log_level = config.get('log_level') log_file_name = config.get('log_file_name') def get_logger(log_level): formatter_str = '%(asctime)s %(levelname)s [%(processName)s] [%(threadName)s] - %(message)s' formatter = logging.Formatter(formatter_str) logging.basicConfig(level=logging.DEBUG, format=formatter_str) Logger = logging.getLogger() file_handler = logging.FileHandler(log_file_name) file_handler.setFormatter(formatter) Logger.addHandler(file_handler) if log_level == 'debug': level = logging.DEBUG elif log_level == 'info': level = logging.INFO else: level = logging.WARNING Logger.setLevel(level) return Logger Logger = get_logger(log_level)