log.py 文件源码

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

项目:stream2segment 作者: rizac 项目源码 文件源码
def configlog4download(logger, db_session, download_id, isterminal):
    """configs for download and returns the handler used to store the log to the db
    and to a tmp file. The file is accessible via logger..baseFilename
    """
    # https://docs.python.org/2/howto/logging.html#optimization:
    logging._srcfile = None
    logging.logThreads = 0
    logging.logProcesses = 0
    # FIXME above: move elsewhere (maybe restoring defaults?)
    logger.setLevel(logging.INFO)  # necessary to forward to handlers
    # custom StreamHandler: count errors and warnings:
    dbstream_handler = DbStreamHandler(db_session, download_id)
    logger.addHandler(dbstream_handler)
    if isterminal:
        # configure print to stdout (by default only info and critical messages)
        logger.addHandler(SysOutStreamHandler(sys.stdout))
    return dbstream_handler


# def configlog4stdout(logger):
#     logger.setLevel(logging.INFO)  # necessary to forward to handlers
#     # configure print to stdout (by default only info and critical messages):
#     logger.addHandler(SysOutStreamHandler(sys.stdout))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号