Beispiel #1
0
def get_logger(name=None):
    if name is None:
        log_file = monitor_log
    else:
        log_file = eos_log_parser_log
    logger = logging.getLogger(log_file)
    logger.setLevel(level)
    if not log_enable:
        logger.disabled = 1
    if file_enable:
        file_handler = MultiprocessHandler(log_file, when='D', backupCount=7)
        file_handler.setFormatter(formatter)
        if len(logger.handlers) == 0:
            logger.addHandler(file_handler)
    if console_enable:
        console_handler = logging.StreamHandler()
        console_handler.setFormatter(formatter)
        if len(logger.handlers) <= 1:
            logger.addHandler(console_handler)
    return logger
Beispiel #2
0
# 定义日志输出格式
formattler = '%(levelname)s - %(name)s - %(asctime)s - %(message)s'
fmt = logging.Formatter(formattler)

# 获得logger,默认获得root logger对象
# 设置logger级别 debug
# root logger默认的级别是warning级别。
# 不设置的话 只能发送 >= warning级别的日志
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

# 使用我们写的多进程版Handler理器,定义日志输出到mylog.log文件内
#   文件打开方式默认为 a
#   按分钟进行日志切割
file_handler = MultiprocessHandler(
    '/home/Model/logs/model_server_logs/model_log', when='D', backupCount=7)
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(fmt)
file_handler.suffix = "%Y-%m-%d.log"
# 对logger增加handler日志处理器
logger.addHandler(file_handler)


class Task_Dis():
    def __init__(self):
        self.error_data = {
            'mode_type': '00',
            "comprehensive_score": '',
            "desc": u"新户A卡评分",
            "status": "DENY"
        }