cli.py 文件源码

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

项目:cosmolog 作者: planetlabs 项目源码 文件源码
def human(verbosity, datefmt, no_color):
    '''Use this command to format machine-readable logs for humans.

    `human` reads stdin and writes formatted lines to stdout.

    Verbosity Levels:
    FATAL=100 | ERROR=200 | WARN=300 | INFO=400 | DEBUG=500 |
    TRACE=600 (DEFAULT)

    USAGE:

    tail -f myapp.log | human

    cat myapp.log | human -v 400 --datefmt "%Y-%m-%d %H:%M:%S"

    '''
    f = CosmologgerHumanFormatter(origin='todo',
                                  version=0,
                                  datefmt=datefmt,
                                  color=not no_color)
    with click.get_text_stream('stdin') as stdin:
        for line in stdin:
            line = line.strip()
            try:
                process(line, verbosity, f)
            except CosmologgerException as e:
                msg = _format_exception(line, e, no_color)
                click.echo(msg, err=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号