log.py 文件源码

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

项目:ceph-medic 作者: ceph 项目源码 文件源码
def setup(config=None):
    root_logger = logging.getLogger()
    log_path = config.get_safe('global', '--log-path', '.')
    if not os.path.exists(log_path):
        raise RuntimeError('configured ``--log-path`` value does not exist: %s' % log_path)
    date = datetime.strftime(datetime.utcnow(), '%Y-%m-%d')
    log_file = os.path.join(log_path, 'ceph-medic-%s.log' % date)

    root_logger.setLevel(logging.DEBUG)

    # File Logger
    fh = logging.FileHandler(log_file)
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(logging.Formatter(FILE_FORMAT))

    root_logger.addHandler(fh)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号