log.py 文件源码

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

项目:ibapi-grease 作者: quantrocket-llc 项目源码 文件源码
def silence_ibapi_logging(levels=["DEBUG", "INFO"]):
    """
    Silences the excessive ibapi logging to the root logger.
    """
    levels = levels or ["DEBUG", "INFO"]

    for level in levels:
        if level not in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"):
            raise ValueError("unknown log level: {0}".format(level))

    for _, module_name, _ in pkgutil.iter_modules(ibapi.__path__):
        module = __import__("ibapi.{0}".format(module_name), fromlist="ibapi")
        if not hasattr(module, "logging"):
            continue

        for level in levels:
            setattr(module.logging, level.lower(), noop)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号