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)
评论列表
文章目录