#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
level_map = {'CRITICAL': logging.CRITICAL,
'ERROR': logging.ERROR,
'WARNING': logging.WARNING,
'INFO': logging.INFO,
'DEBUG': logging.DEBUG,
'NOTSET': logging.NOTSET}
# get root logger
log_root = logging.getLogger()
# get logger
def get_logger(module_name, string_level):
# 基本设置
str_formatter = '%(asctime)s|%(levelname)s|%(thread)d|%(filename)s|%(funcName)s:%(lineno)d|%(message)s'
logging.basicConfig(level=level_map[string_level], format=str_formatter)
# 获取logger
logger = logging.getLogger(module_name)
return logger