utils.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:python-zhmcclient 作者: zhmcclient 项目源码 文件源码
def setup_logger(log_comp, handler, level):
    """
    Setup the logger for the specified log component to add the specified
    handler (removing a possibly present NullHandler) and to set it to the
    specified log level. The handler is also set to the specified log level
    because the default level of a handler is 0 which causes it to process all
    levels.
    """

    name = LOGGER_NAMES[log_comp]
    logger = logging.getLogger(name)

    for h in logger.handlers:
        if isinstance(h, logging.NullHandler):
            logger.removeHandler(h)

    handler.setLevel(level)
    logger.addHandler(handler)
    logger.setLevel(level)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号